//对象
#include
#include
using namespace std;
class stu {//类的定义
public://公共的
string name;
int age = 0;//c++11允许赋值
string sex;
string zhuanye;
//类中可以写方法
void read(stu a);
void caozuo();
}zhaoyi,qianer;
void caozuo() {
cout << " ? ? ? ? ? ? ? ? ? ";
}
void read(stu a) {
cout << "*****************"<< endl;
cout << a.name << endl;
cout << a.age << endl;
cout << a.sex << endl;
cout << a.zhuanye << endl;
cout << "*****************" << endl;
}
int main() {
stu sunsan;
//zhaoyi.age = 20;
zhaoyi.name = "赵艺";
zhaoyi.sex = "女";
cin>>zhaoyi.zhuanye;
sunsan = zhaoyi;//直接拷贝
read(sunsan);
caozuo();
}
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)