VC出错。错在那啊,不懂,我新学啊
#include <iostream>#include<string>
using namespace std;
class teacher
{public:
teacher(string nam,int a,string t)
{name=nam;
age=a;
title=t;}
void display()
{cout<<"name:"<<name<<endl;
cout<<"age:"<<age<<endl;
cout<<"title:"<<title<<endl;
}
protected:
string name;
int age;
string title;
};
class student
{public:
student(char nam[],char s,float sco)
{strcpy(namel,nam);
sex=s;
score=sco;}
void display()
{cout<<"name:"<<namel<<endl;
cout<<"sex:"<<sex<<endl;
cout<<"score:"<<score<<endl;
}
protected:
string namel;
char sex;
float score;
};
class graduate:public teacher,public student
{public:
graduate(string nam,int a,char s,string t,float sco,float w):
teacher(nam,a,t),student(nam,s,sco),wage(w){}
void show()
{cout<<"name:"<<namel<<endl;
cout<<"age:"<<age<<endl;
cout<<"sex:"<<sex<<endl;
cout<<"score:"<<score<<endl;
cout<<"title:"<<title<<endl;
cout<<"wager:"<<wager<<endl;
}
private:
float wage;
};
int main()
{graduate gradl("wang",24,'f',"assistant",1234.5,123.5);
gradl.show();
return 0;
}