求助,调试的问题
可以编译,但调试时出现怎不能贴图unhanded excpton in ......
#include<iostream.h>
#include<conio.h>
#include<string.h>
class base{
private:
char *name;
int age;
public:
base(){
}
void setname(char a[]){
name=new char[strlen(a)+1];
strcpy(name,a);
}
void setage(int a){
age=a;
}
char* getname(){
return name;
}
int getage(){
return age;
}
};
class leader:virtual public base{
char *job;
char *dep;
public:
leader(){
}
void setjob(char jb[]){
job=new char[strlen(jb)+1];
strcpy(job,jb);
}
void setdep(char dp[]){
dep=new char[strlen(dp)+1];
strcpy(dep,dp);
}
char* getjob(){
return job;
}
char* getdep(){
return dep;
}
};
class engineer: virtual public base{
char *major;
char *prof;
public:
engineer(){
}
void setmajor(char maj[]){
major=new char[strlen(maj)+1];
strcpy(major,maj);
}
void setprof(char pf[]){
prof=new char[strlen(pf)+1];
strcpy(prof,pf);
}
char* getmajor(){
return major;
}
char* getprof(){
return prof;
}
};
class chairman:public leader,public engineer{
};
void main(){
chairman c;
c.setname("LY");
c.setage(20);
c.setjob("教授");
c.setdep("LY研究所");
c.setprof("高级电子工程师");
cout<<"输出结果:"<<endl;
cout<<" "<<c.getname()<<", 年龄"<<c.getage()<<"岁"<<endl;
cout<<" "<<"担任"<<c.getdep()<<c.getjob()<<", "<<c.getprof()<<endl;
cout<<" "<<"从事"<<c.getmajor()<<"专业"<<"."<<endl;
getch();
}