#include<iostream>
using namespace std;
class Time
{private:
int HH,MM,SS;
public:
Time(int H=0,int M=0,int S=0):HH(H),MM(M),SS(S){}
Time&operator++();
Time&operator++(int);
void display();
};
Time&Time::operator++()
{SS++;
if(SS==60)
{MM++;
SS=0;}
if(MM==60)
{HH++;
MM=0;}
return *this;
}
Time&Time::operator++(int)
{
Time temp;
temp=*this;
++temp;
return temp;
}
void Time::display()
{
cout<<"此时时间是:"<<endl;
cout<<HH<<":"<<MM<<":"<<SS<<endl;
}
int main()
{
Time A1(21,20,59),A2;
A1.display();
A2.display();
A2=++A1;
A1.display();
A2.display();
A2=A1++;
A1.display();
A2.display();
system("pause");
return 0;
}
using namespace std;
class Time
{private:
int HH,MM,SS;
public:
Time(int H=0,int M=0,int S=0):HH(H),MM(M),SS(S){}
Time&operator++();
Time&operator++(int);
void display();
};
Time&Time::operator++()
{SS++;
if(SS==60)
{MM++;
SS=0;}
if(MM==60)
{HH++;
MM=0;}
return *this;
}
Time&Time::operator++(int)
{
Time temp;
temp=*this;
++temp;
return temp;
}
void Time::display()
{
cout<<"此时时间是:"<<endl;
cout<<HH<<":"<<MM<<":"<<SS<<endl;
}
int main()
{
Time A1(21,20,59),A2;
A1.display();
A2.display();
A2=++A1;
A1.display();
A2.display();
A2=A1++;
A1.display();
A2.display();
system("pause");
return 0;
}