作者u9555kimo ()
看板PCCU-CS
标题[其它] time6.h && fig17_08.cpp
时间Mon May 14 03:41:42 2007
因应观众需求...
#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