刘氏中国研究院:谁帮我解VC++

来源:百度文库 编辑:神马品牌网 时间:2024/05/09 04:38:28
创建一个日期类Day,创建一个Person类(姓名、身份证号码,出生日期)。再创建两个类Student和Faculty,均继承于Person类,且它们都增加了自己新特性,其中Student增加了班级和学号,Faculty增加了工号和教龄。分别输入两名学生和两位教师的相应信息,并在屏幕上输出。

#include <iostream.h>
struct day
{
int year;
int month;
int day1;
};

class person
{
public:
char name[10];
char sfz[20];
day birth;
};

class student:public person
{
public:
char bj[10];
char xh[10];

};

class Faculty:public person
{
char gh[10];
int age;
}

main()
{
int i;
student stu;
for(i=1;i<=2;i++)
{
cout<<"输入学生学号:";
cin>>stu.xh;
cout<<"输入学生姓名:";
cin>>stu.name;
cout<<"输入学生班级:";
cin>>stu.bj;
cout<<"输入学生身份证号:";
cin>>stu.sfz;
cout<<"输入学生出生日期:";
cin>>stu.birth.year>>stu.birth.month>>stu.birth.day1;
cout<<"学号:"<<stu.xh<<endl;
cout<<"姓名:"<<stu.name<<endl;
cout<<"班级:"<<stu.bj<<endl;
cout<<"身份证号:"<<stu.sfz<<endl;
cout<<"出生日期:"<<stu.birth.year<<".";
cout<<stu.birth.month<<".";
cout<<stu.birth.day1<<endl;

}
}

自己参考下,不完全对.