看看我这样行不行
#include<iostream>
#include<stdlib.h>
using namespace std;
class Time
{
int hour;
int minute;
int second;
public:
Time()
{
hour = 0;
minute = 0;
second = 0;
}
Time(int hour, int minute = 0, int second = 0)
{
hour = hour;
minute = minute;
second = second;
}
void setTime(int x,int y,int z)
{
hour = x;
minute = y;
second = z;
}
void setTime(int x,int y)
{
minute = x;
second = y;
}
void setTime(int x)
{
second = x;
}
void display()
{
cout << hour << ":" << minute << ":" << second << endl;
}
};
int main()
{
Time time;
time.setTime(12,30,50);
time.display();
time.setTime(35);
time.display();
time.setTime(42,31);
time.display();
system("pause");
}