看板 PCCU-CS 關於我們 聯絡資訊
因應觀眾需求... #ifndef TIME6_H #define TIME6_H class Time { public: Time( int = 0, int = 0, int = 0 ); // default constructor // set functions Time &setTime( int, int, int ); // set hour, minute, second Time &setHour( int ); // set hour Time &setMinute( int ); // set minute Time &setSecond( int ); // set second // get functions (normally declared const) int getHour() const; // return hour int getMinute() const; // return minute int getSecond() const; // return second // print functions (normally declared const) void printMilitary() const; // print military time void printStandard() const; // print standard time private: int second; // 0 - 59 }; // end class Time #endif ----------------------------------------------------------------------- // Cascading member function calls together // with the this pointer #include <iostream> using std::cout; using std::endl; #include "time6.h" int main() { Time t; t.setHour( 18 ).setMinute( 30 ).setSecond( 22 ); cout << "Military time: "; t.printMilitary(); cout << "\nStandard time: "; t.printStandard(); cout << "\n\nNew standard time: "; t.setTime( 20, 20, 20 ).printStandard(); cout << endl; system("pause"); return 0; } // end function main -- 謝謝你!!                  使一個人感動很容易 我好感動~~ 哈 這哪算得了什麼         使一個人心動卻只能看天意 /     >   因為 我喜歡妳..  ▲     ■    ●但..我們還是當好朋友吧^^  ∥      ∥           ■     http://www.wretch.cc/blog/lightpink1 ∥    ∥ -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 125.225.137.113