Posted on 2011-07-16 20:12
susu 阅读(573)
评论(0) 编辑 收藏 引用
#include <iostream>
#include <string>
using namespace std;
class stud
{
protected:
int num;
char name[10];
char sex;
public:
stud(int n,char nam[],char s)
{
num = n;
strcpy(name,nam);
sex = s;
}
//~stud(){}
};
class student : public stud
{
private:
int age;
char addr[30];
public:
student(int n,char nam[],char s,int a,char ad[]):stud(n,nam,s)
{
age = a;
strcpy(addr,ad);
}
void show()
{
cout << "num:" << num << endl;
cout << "name:" << name << endl;
cout << "sex:" << sex << endl;
cout << "age:" << age << endl;
cout << "address:" << addr << endl;
}
~student(){}
};
void main()
{
student a(10010,"wangli",'f',19,"shanghai");
student b(10011,"zhangfun",'m',21,"hangzhou");
a.show();
cout << endl;
b.show();
}