时钟程序求大神解答。
#include<iostream>using namespace std;
class Clock
{public:
Clock();
void SetTime (int NewH,int NewM,int NewS);
void ShowTime();
~Clock(){}
Private:
int Hour;
int Minute;
int Second;
};
Clock::Clock()
{
Hour=0;
Minute=0;
Second=0;
}
void Clock::SetTime(int NewH,int NewM,int NewS)
{
Hour=NewH;
Minute=NewM;
Second=News;
}
void Clock::ShowTime()
{
cout<<Hour
<<":"
<<Minute
<<":"
<<Second
<<":"
<<endl;
}
Clock globClock;
int main()
{
cout << "The first time output:"<< endl;
globClock.ShowTime();
globClock.SetTime(8,30,30);
Clock myClock(globClock);
cout << "The second time output:"<<endl;
myClock.ShowTime();
}