#include <iostream>
using namespace std;
//设计一个学生类,属性有姓名和学号
//可以给姓名和学号赋值,可以显示学生的姓名和学号
//设计学生类
class Student
{
public: //公共权限
//属性
string m_Name; //姓名
int m_Id; //学号
//行为
//显示姓名和学号
void showStudent()
{
cout << "姓名:" << m_Name << " 学号:" << m_Id << endl;
}
};
int main()
{
//创建一个具体的学生 实例化对象
Student s1;
s1.m_Name = "张三";
s1.m_Id = 1;
s1.showStudent();
Student s2;
s2.m_Name = "李四";
s2.m_Id = 2;
s2.showStudent();
system("pause");
}
06-12
1万+
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountBlack.png)
01-25
04-24
7808
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountBlack.png)
06-07
2万+
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountBlack.png)
“相关推荐”对你有帮助么?
-
非常没帮助
-
没帮助
-
一般
-
有帮助
-
非常有帮助
提交