實驗:編寫乙個人員資訊管理系統。這個系統的功能是:互動式地實現校園人員資訊的錄入與顯示。
分析:學校裡,主要有四類人員:大學本科學生、教師、研究生和助教。
大學本科生每週有固定的學時數。教師除了固定的學時數外,還有每週的教學時數。研究生除了固定的學時數外,每週還可以自由做一定的研究。助教除了上課外,還要做研究和一定的教學工作。
人員的基本資訊包括姓名、編號、性別、身份證號、總學時數、以及每週固定學時數。各個人員之間的關係:people類派生出student類和teacher類,student類派生出graduate類,graduate類和teacher類派生出ta類。
以下給出部分程式:
#include
using namespace std;
class people
;class student: virtual public people
;class teacher: virtual public people
;class graduate: virtual public student
;class ta: public graduate, public teacher
;void main()
#include
using
namespace std;
class
people
;class
student
:virtual
public people
;// student 建構函式
student::
student
(double time)
:learn_time
(time)
//student >>運算子過載
istream&
operator
>>
(istream& in, student& x)
//student類輸出
void student::
print1()
//class
teacher
:virtual
public people
;//teacher 建構函式
teacher::
teacher
(double telearning,
double teach)
:telearning_time
(telearning)
,teach_time
(teach)
//teacher類輸出
void teacher::
printte()
//teacher >>型別符過載
istream&
operator
>>
(istream& in, teacher& x)
//class
graduate
:virtual
public student
;//graduate 建構函式
graduate::
graduate
(double learning,
double reserching)
:student
(learning)
,research
(reserching)
//graduate >>過載
istream&
operator
>>
(istream& in, graduate& x)
//graduate 輸出
void graduate::
printga()
classta:
public graduate,
public teacher
;//ta 建構函式
ta::ta(
double learning,
double reserching,
double teaching_time)
:graduate
(learning, reserching)
,teacher(0
, teaching_time)
,student(0
);//ta >>過載
istream&
operator
>>
(istream& in, ta& x)
//ta 輸出
void ta::
printta()
intmain()
C程式設計實驗報告
c程式設計實驗報告 1 了解字元在計算機中以ascii碼方式表示,了解字元的型別 字長其數的表示範圍。2 掌握c語言資料型別,熟練掌握變數定義 3 使用scanf 輸入變數的值,使用printf 輸出變數 4 掌握運算子與表示式的使用方法及其優先順序和結合性規律。5 鞏固對演算法概念的理解,掌握運算...
C程式設計實驗報告
試驗專案 1.字元與ascll碼 2.運算子與表示式的運用 3.順序結構應用程式 4.數學函式的演算法描述 5.雞兔同籠的演算法描述 6.確定座標的演算法描述 一,實驗目的與要求 1.實驗目的 具體要求 1 從鍵盤輸入任意字元,且在輸入前要求有提示資訊。2 輸出兩行 第一行是字元形式輸出3個字元,3...
C語言程式設計實驗報告 實驗一
二 第二個c程式 個人總結 實驗一,說實話沒必要寫出來,主要是給剛入門c語言的同學提供那麼一丟丟幫助 其實幫助也不大 需要完成兩個c程式的編寫 其實乙個就可以解決問題 1 編寫程式,在螢幕上輸出 hello world 這個實驗我用的是dev c 因為這個程式還用不著visual studio之類的...