/*重载<<与>>进行时间类的输入输出*/
#include
using namespace std;
class Clock
{
private:
int H,M,S;
public:
void SetTime(int h,int m,int s)
{
H=(h>=0&&h<24)? h:0;
M=(m>=0&&m<60)? m:0;
S=(s>=0&&s<60)? s:0;
}
void ShowTime()
{
cout< }
//重载>>输入clock类值(>>运算符只能重载为类的非成员函数)
friend istream & operator>>(istream & input,Clock&c)
{
input>>c.H;
input.ignore();
input>>c.M;
input.ignore();
input>>c.S;
return input;
}
//重载>>输出clock类值
friend ostream & operator<< (ostream & output,const Clock & c)
{
output< return output;
}
};
int main()
{
Clock c1;
cin>>c1;
cout< return 0;
}
阅读(409) | 评论(0) | 转发(0) |