虛基類 在職讀書的教師類

2021-07-03 14:01:15 字數 909 閱讀 5041

定義並描述乙個人員類person,它派生出學生類student和教師類teacher,學生類和教師類又共同派生出在職讀書的教師類stutech。人員類有姓名、性別、身份證號、出生年月等資訊;學生類除繼承來的以外有學號、成績等資訊;教師類有職稱等資訊。要求:將相應的類定義完整,並在main函式中定義stutech的物件,輸出物件的所有資訊。

輸入包括多組測試資料,每組資料報括:姓名,性別,身份證,出生年,月,學號,成績,職稱

每組測試資料輸出多行

tom man 350100198505020035 1985 5 2011010230 85 lecturer

the imformation of study-teacher is:

name:tom ***:man identity card:350100198505020035 birthday:1985.5

num:2011010230 score:85

profession:lecturer

wj14信管期末複習上機練習a

zh#include

using namespace std;

class person

void show()

~person()

{}};

class student:public person

void show()

~student()

{}};

class teacher:public person

void show1()

};class stutech:public student,public teacher

void show()

};int main()

return 0;

完整不是水的!!!!

虛基類的應用 人與教師學生

派生類定義 根據所給的基類,完成多重繼承下的派生類定義 函式介面定義 include include using namespace std 定義公共基類person class person protected string name char int age 定義類teacher class t...

虛基類 虛函式和純虛基類

首先看乙個例子 class base class child1 public base class child2 public base void main else p print 函式呼叫的時候,檢視虛表,根據p的位址首先從虛表裡面查詢要呼叫的函式 這裡呼叫child2的print 函式 ret...

虛基類釋義

include stdafx.h include include using namespace std class person class teacher virtual public person class student virtual public person class gradua...