class student //基类
{
protected:
char num[10];
char name[10];
char sex;
public:
void display()
{
cout<<"num: "<<num<<endl;
cout<<"name:"<<name<<endl;
cout<<"sex: "<<sex<<endl;
}
student(char n[],char na[],char s) //
{
strcpy(num,n);
strcpy(name,na);
sex=s;
}
~student()
{
}
};
class stud:public student
{
private :
int age;
char address[30];
public :
void display_1()
{
display();
cout<<"age:"<<age<<endl;
cout<<"address:"<<address<<endl;
}
stud(char n[],char na[],char s,int a,char addr[]):student(n,na,s)
{
age=a;
strcpy(address,addr);
}
};
int _tmain(int argc, _TCHAR* argv[])
{
stud A("0001","wan_min",'f',19,"ShangHai");
stud B("0002","Li_li",'m',20,"AnHui");
A.display_1();
B.display_1();
return 0;
}