time类的程序代码.docx

(1)time类 #include iostream using namespace std; class Time { private: int hour; int minute; int sec; public: void set(int h,int m,int s); void print() { couthour:minute:secendl; } }; void Time::set(int h,int m,int s) { hour = h; minute = m; sec = s; } int main() { Time t1; t1.set(12,34,56); t1.print(); return 0; } (2)date类 #includeiostream using namespace std; // class Date { protected: int year, month, day; void init() { if(year5000||year1||month1||month12||day1||day31) exit(1); //停机 } public: Date(int y=2000, int m=1, int d=1); bool isLeapYea

文档评论(0)

1亿VIP精品文档

相关文档