#include <iostream>
using namespace std;
class Time{
public:
Time(int Hour, int Minute, int Second)
{
hour = Hour;
minute = Minute;
second = Second;
}
Time()
{
hour = minute = second = 0;
}
~Time()
{
cout<<"Goodbye!"<<endl;
}
void print_time()
{
cout<<hour<<":"<<minute<<":"<<second<<endl;
}
int getHour()
{
return hour;
}
int getMinute()
{
return minute;
}
int getSecond()
{
return second;
}
Time(Time &time)
{
hour = time.getHour();
minute = time.getMinute();
second = time.getSecond();
}
private:
int hour, minute, second;
};
int main()
{
Time a(12, 34, 56), b;
a.print_time();
b.print_time();
b = a;
b.print_time();
return 0;
}
温馨提示:答案为网友推荐,仅供参考