看板 Programming 關於我們 聯絡資訊
class Time {//第六行,forward declaration of 'class Time' public: Time(); //第八行,invalid use of incomplete type 'class Time' void setTime(int, int, int); void printUniversal(); void printStandard(); private: int hour; int minute; int second; }; Time::Time(){ hour = minute = second = 0; } void Time::setTime(int h, int m, int s) { hour = ((h>=0)&&(h<=23)?h:0); minute = ((m>=0)&&(m<=59)?m:0); second = ((s>=0)&&(s<=59)?s:0); } void Time::printUniversal() { cout << hour << ":" << minute << ":" << second << endl; }; void Time::printStandard() { cout << ((hour == 0 || hour == 12) ? 12 : hour % 12) << ":" << minute << ":" << second << (hour < 12 ? "AM": "PM") << endl; }; int main() { Time t; t.printUniversal(); t.printStandard(); t.setTime(23,59,59); t.printUniversal(); t.printStandard(); system("pause"); return 0; } -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 123.195.32.199
dryman:linux的話不用加system("pause"); 220.136.186.2 01/06 22:34
mantour:基本上在command line執行都不用加140.112.213.158 01/06 22:41
tw00088437:好眼熟...螞蟻書 61.228.26.231 01/06 23:32