我只是想超载+运营商,我得到这个编译器警告C++编译器警告 - 返回局部变量
reference to local variable 'tmp' returned
下面是超载
const Int& Int::operator+(const Int& p) const
{
Int tmp = value + p.value;
return tmp;
}
这里的代码是类
class Int{
int value;
public:
Int() {} // default constructor
Int(int v) : value(v) {}
Int& operator=(const Int&);
const Int& operator+(const Int&) const;
};