/*设计一个基类BASE,包括编号,姓名,住址以及相关的成员函数,
由它派生出学生类student和教师teacher*/
#include
#include
using namespace std;
class base{
int id;
string name;
string address;
public:
base(int i,string n,string a) {id=i;name=n;address=a;}
~base() {}
display() {cout< setid(int x) {id=x;}
};
class teacher:public base{
public:
teacher(int ii,string nn,string aa):base(ii,nn,aa) {}
~teacher() {}
};
class student:public base{
public:
student(int aa,string bb,string cc):base(aa,bb,cc) {}
~student() {}
};
void main()
{teacher t(1001,"jia","黑龙江");
student s(96001,"jie","浙江");
t.setid(1002);
s.setid(96002);
t.display();
s.display();}
--------------------next---------------------
阅读(1171) | 评论(0) | 转发(0) |