?? p329 例 10.5 運(yùn)算符重載.cpp
字號(hào):
#include<iostream>
using namespace std;
class Time
{
private:
int second;
int minute;
public:
Time();
Time(int a,int b):minute(a),second(b){}
Time operator ++();
void display();
};
Time::Time()
{
second=0;
minute=0;
}
Time Time::operator ++()
{
second++;
if(second>=60) {second=0; minute++; }
return *this;
}
void Time::display()
{
cout<<minute<<":"<<second<<endl;
}
int main()
{
Time t(34,5);
int i;
for(i=0;i<61;i++)
{ ++t;
t.display();
}
system("pause");
return 0;
}
?? 快捷鍵說(shuō)明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -