#include<iostream>
using namespace std;
class Clock
{
private:
int hour,minute,second;
public:
int setTime(int h,int m,int s);
int showTime();
};
int Clock::setTime(int h=0,int m=0,int s=0)
{
hour=h;
second=s;
minute=m;
return 0;
}
int Clock::showTime()
{ cout<<"时间为:"<<endl;
cout<<hour<<":"<<minute<<":"<<second<<endl;
return 0;
}
int main()
{
Clock c1;
c1.setTime();
c1.showTime();
Clock *time1;
time1->setTime(1,2,3);
time1->showTime();
Clock c3;
Clock *time2=&c3;
time2->setTime(2,4,6);
time2->showTime();
return 0;
}
using namespace std;
class Clock
{
private:
int hour,minute,second;
public:
int setTime(int h,int m,int s);
int showTime();
};
int Clock::setTime(int h=0,int m=0,int s=0)
{
hour=h;
second=s;
minute=m;
return 0;
}
int Clock::showTime()
{ cout<<"时间为:"<<endl;
cout<<hour<<":"<<minute<<":"<<second<<endl;
return 0;
}
int main()
{
Clock c1;
c1.setTime();
c1.showTime();
Clock *time1;
time1->setTime(1,2,3);
time1->showTime();
Clock c3;
Clock *time2=&c3;
time2->setTime(2,4,6);
time2->showTime();
return 0;
}