首页 > 其他 > 详细

[基础] 重载的时候什么时候用引用&

时间:2016-03-18 01:42:19      阅读:299      评论:0      收藏:0      [点我收藏+]

一般返回值还要继续被处理,而不仅仅是得到其值的时候,返回引用&

一般有[], =, ++, --, 还有输入输出运算符<<, >>

Classtype &operator++() {
    ++this->num;
    return *this;
}
//调用前置版本
const Classtype operator++(int) {
    Classtype old(*this);
    //++this->num;
    ++*this
    return old;
}

 

[基础] 重载的时候什么时候用引用&

原文:http://www.cnblogs.com/littletail/p/5290087.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!