一道C语言题目,求教,非常感谢

2024-11-13 21:50:49
推荐回答(1个)
回答1:

#include
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!"< }
void print_time()
{
cout< }
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;
}