#c++程序语言设计戴波-
第八章:课上实验
时钟类
问题:实现时钟类时构造了函数但是不能用。
解决办法:c++中clock()是C/C++中的计时函数,将clock改成大写的Clock即
可。
修改后代码如下:
#include<iostream>
#include"clock.h"
using namespace std;
//使用类
int main()
{
int h, m, s;
cin >> h >> m >> s;
Clock c1(h,m,s),c2(c1);
c1.settime(10, 20, 30);
c1.gettime(h, m, s);
cout << "c1:" << h << ":" << m << ":" << s << endl;
c2.showtime();
}