#include <iostream>
#include<cstring>
using namespace std;
class base
{
int age;
char* name;
public:
base(int a,char* na)
{
age=a;
name=new char[strlen(na)+1];
strcpy (name,na);
}
virtual void display()=0;
~base(){}
//delete char;
};
class leader:virtual public
base
{
char* zhiwei;
char* depart;
public:
leader(na,a,char* zhi,char* dep):base(a,na)
{
zhi=new char[strlen(zhi)+1];
strcpy (zhiwei,zhi);
dep=new char[strlen(dep)+1];
strcpy (depart,dep);
}
void display()
{
cout<<"姓名"<<name<<"年龄"<<age<<"职位"<<zhiwei<<"部门"<<depart<<endl;
}
~leader(){}
//delete char;
};
class engineer:virtual public base
{
char* zhicheng;
char* career;
public:
engineer(na,a,char* zhic,char* car):base(a,na)
{
zhic=new char[strlen(zhic)+1];
strcpy (zhicheng,zhic);
car=new char[strlen(car)+1];
strcpy(career,car);
}
void display()
{
cout<<"姓名"<<name<<"年龄"<<age<<"职称"<<zhicheng<<"职业"<<career<<endl;
}
~engineer(){}
//delete char;
};
class chairman:public leader,public engineer
{
public:
chairman(int a,char* na,char* zhi,char* dep,char* zhic,char* car):leader(a,na,zhi,dep),engineer(zhic,car){}
void display()
{
cout<<"姓名"<<name<<"年龄"<<age<<"职称"<<zhicheng<<"职业"<<career<<"职位"<<zhiwei<<"部门"<<depart<<endl;
}
};
void main()
{
leader L("三弟",28,"书记","团委");
L.display();
engineer e("二哥",29,"助教","电子工程");
e.display();
chairman c("一哥",40,"主任","电子工程","教授","办公室");
c.display();
}
这样子了 调试通不过 还是很多 错的 怎么改呢?