笔记:C++重载++前后区分

a++

++a

++有2种方式,那么在重载++的时候要怎么区分:

前置:

T& operator++(){

    do something

    return *this;

}

后置:

const T operator++(int){

    T tmp = *this;

    ++(*this);

    return tmp;

}

区别主要在:

1.返回值

2.函数参数

 

原文地址:https://www.cnblogs.com/-maybe/p/7491485.html