用构造函数和类的方法设计一个时钟程序 关于C++的 在线等,,谢谢啊

来源:百度知道 编辑:UC知道 时间:2024/06/18 14:30:55
用构造函数和类的方法设计一个时钟程序
解答者送分啊

#include<iostream>
#include<ctime>
using namespace std;
class Clock
{
friend void main();
public:
Clock(int a,int b,int c)
{
hour=a;
minute=b;
second=c;
}
private:
int hour;
int minute;
int second;
};
void main()
{
time_t timep;
time(&timep);
struct tm *p=localtime(&timep);
Clock o(p->tm_hour,p->tm_min,p->tm_sec);
cout<<"now is "<<o.hour<<":"<<o.minute<<":"<<o.second<<endl;
}
你认为可以 就把分给我