64,642
社区成员
发帖
与我相关
我的任务
分享
#include <iostream>
#include <string>
using namespace std;
class CStudent{
public:
CStudent();
CStudent(string s);
string sName; // 姓名
string sNativePlace; // 籍贯
string sStudentID; // 学号
string sInfo;
int iAge; // 年龄
int iScorePlace; // 排名
void Display(void);
private:
string sStyle;
};
CStudent::CStudent(string s){
sStyle = s;
}
void CStudent::Display(void){
cout << sStyle << "信息: " << endl;
cout << " --> 姓名: " << sName << endl;
cout << " --> 籍贯: " << sNativePlace << endl;
cout << " --> 学号: " << sStudentID << endl;
cout << " --> 年龄: " << iAge << endl;
cout << " --> 排名: " << iScorePlace << endl;
if (sStyle == "导师")
cout << " --> 导师信息: " << sInfo << endl;
cout << endl;
}
class CMaster: public CStudent{
public:
CMaster();
CMaster(string s);
};
int main(void){
CMaster master("导师");
master.iAge = 22;
master.iScorePlace = 1;
master.sInfo = "QQ 272399954";
master.sName = "X.Rabbit";
master.sNativePlace = "HongKong";
master.sStudentID = "ID Number 1";
master.Display();
system("PAUSE>NUL");
return 0;
}