C 語言程式設計課後習題

2021-10-05 09:35:01 字數 1346 閱讀 1106

#4-10 設計乙個用於人事管理的「人員」類。由於考慮到通用性,這裡只抽象出所有型別

人員都具有的屬性:編號、性別、出生日期、身份證號等。其中「出生日期」宣告為

乙個「日期」類內嵌子物件。用成員函式實現對人員資訊的錄入和顯示。要求包

括:建構函式和析構函式、複製建構函式、內聯成員函式、帶預設形參值的成員函

數、類的組合。

這個**還有很多不足(但執行是正確的),希望各位大佬可以給點建議

#include

using

namespace std;

class

date

intgetmonth()

intgetday()

void

showdate()

;~date()

;private

:int year;

int month;

int day;};

//日期

date::

date

(int ayear,

int amonth,

int aday )

date::

date

( date &d )

void date::

showdate()

//員工

class

people

;private

:int number;

//編號

string ***;

//性別

date birthday;

//出生日期

string id;

//身份證號};

people::

people

(int anumber, string a***, date abirthday, string aid)

:number

(anumber)

,***

(a***)

,birthday

(abirthday),id

(aid)

;people::

people

( people &p)

:birthday

( p.birthday)

void people::

inputinformation

(int anumber, string a***, date abirthday, string aid )

void people::

displayinformation()

intmain()

return0;

}

C語言程式設計課後習題 9 1 8 4

標題 交換變數 帶參的巨集 description 定義乙個帶參的巨集,使兩個引數的值互換,並寫出程式,輸入兩個數作為使用巨集時的實參。輸出已交換後的兩個值。input 兩個數,空格隔開 output 交換後的兩個數,空格隔開 sample input copy 1 2sample output c...

C語言程式設計課後習題 第3章

分析並寫出下列程式的執行結果 1 include intmain void 輸出 18.0 2 2 include intmain void 輸出 32 8033 80參考例3.1程式,從鍵盤任意輸入乙個3位整數,程式設計計算並輸出它的逆序數 忽略整數前的正負號 例如,輸入 123,則忽略負號,由1...

C語言程式設計課後習題 第5章

從鍵盤任意輸入乙個實數,不使用計算絕對值函式程式設計計算並輸出該實數的絕對值 include include intmain printf f n x return0 從鍵盤任意輸入乙個整數,程式設計判斷它的奇偶性 include include intmain else return0 在例3.8...