1392: Clock类初步设计
Description
设计时钟Clock类,包含私有成员数据hour,minute,second,成员函数包括:不带参数的构造函数(三个成员数据的值默认为0,同时显示“Default Constructor is called!“);带3参数的构造函数(用来初始化三个成员数据的值,同时显示“Constructor is called!“);设置修改三个成员数据值的函数SetClock;显示时钟函数Show(格式形如“时:分:秒”)。
main函数如下:(大家提交时不用包含main函数)
int main()
{
Clock c1,c2(1,2,3);
c1.Show();
c2.Show();
c1.SetClock(23,59,59);
c1.Show();
c2.Show();
return 0;
}
Sample Output
Default Constructor is called!
Constructor is called!
0:0:0
1:2:3
23:59:59
1:2:3
AC代码如下:
#include