# Include "stdafx. h"
# Include
# Include
Using namespace std;
Class person {// declare the base class
Protected:
Int age;
Char sex;
String name;
Public:
Person (int a, char s, string nam ){
Age =;
Sex = s;
Name = nam;
}
};
Class teacher: virtual public person
{
Protected:
String title;
Public:
Teacher (int a, char s, string nam, string t): person (a, s, nam ){
Title = t;
}
};
Class student: virtual public person
{
Protected:
Float score;
Public:
Student (int a, char s, string nam, float SC): person (a, s, nam ){
Score = SC;
}
};
Class graduate: public teacher, public student
{
Protected:
Float wdge;
Public:
Graduate (int a, char s, string nam, string t, float SC, float wd): person (a, s, nam), teacher (a, s, nam, t), student (a, s, nam, SC ){
Wdge = wd;
}
Void show (){
Cout}
};
Int main (){
Graduate gr (22, 'F', "k; asdjf; daf", "klsdaf", 89.5, 79.5 );
Gr. show ();
Return 0;
}
Output result:
K; asdjf; daf
22
F
Klsdaf
89.5
79.5
Press any key to continue
Trackback: http://tb.blog.csdn.net/TrackBack.aspx? Postid = 1476036