第7周專案2 友元類

2021-07-11 16:51:05 字數 462 閱讀 2144

#include using namespace std;

class date; //對date類的提前引用宣告

class time

;class date

;int main( )

return 0;

}//下面定義兩個類中的成員函式,要求不得再增加成員函式

//注意體會在time的成員函式中可以呼叫date類的私有資料成員

time::time(int h,int m,int s)

date::date(int m,int d,int y)

int days(int m, int y); //days函式返回y年m月的天數

void time::add_a_second(date &d)

void time::display(date &d)

{ cout<

學習心得:這個其實並不太懂!!

第7周專案2 友元類(時間的高階)

檔名稱 test.cpp 版本 code blocks 問題描述 宣告主權 輸入描述 程式輸出 include using namespace std class date 對date類的提前引用宣告 class time class date time time int h,int m,int s...

第6周專案5 友元類

檔名稱 test.cpp 作 者 劉暢 完成日期 2015年 4 月 12 日 版 本 號 v1.0 問題描述 定義下面兩個類的成員函式 為體驗友元類,實際上本例並不一定是乙個好的設計,將兩個類的合併為乙個datetime,日期 時間都處理更好 輸入描述 null 程式輸出 按要求輸出。如下 inc...

第6周專案5 友元類

檔名稱 main.cpp 完成日期 2015年 4月15日 版本號 v1.0 問題描述 定義下面兩個類的成員函式 為體驗友元類,實際上本例並不一定是乙個好的設計,將兩個類的合併為乙個datetime,日期 時間都處理更好 輸入描述 程式輸出 編寫的程式 include using namespace...