首页 > 代码库 > C++运算符重载

C++运算符重载

可看一博主文章http://blog.csdn.net/insistgogo/article/details/6626952

 

下面是自+1的函数重载

//单目运算符重装++, --
Person& operator++() //++a;
{
this->age += 1;
return *this;
}

Person operator++(int) //a++
{
Person old(*this);
this->age += 1;
return old;
}

C++运算符重载