#include <iostream>
using namespace std;
/*运算符重载 -- 单目运算符 ++, --, *, ->
格式: return_type operator symbol(params list...)
*/
class Base {
private:
unsigned int numBase;
public:
/*operator ++i 的实现*/
Base& operator ++ () {
++numBase;
return *this; //this指当前对象的地址,*this指当前对象
}
/*operator --i 的实现*/
Base& operator -- () {
--numBase;
return *this; //this指当前对象的地址,*this指当前对象
}
/*operator i++ 的实现, 实现后++,需要在()加参数*/
Base operator ++ (int) {
Base CopyObject(numBase);
++numBase;
return CopyObject;
}
/*operator i-- 的实现, 实现后--,需要在()加参数*/
Base operator -- (int) {
Base CopyObject(numBase);
--