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;
}

posted on 2017-07-24 16:41  别人都叫我陈科  阅读(108)  评论(0编辑  收藏  举报

导航