J'essaie simplement de surcharger un opérateur + et je reçois ce compilateur avertissementC++ avertissement du compilateur - retour variable locale
reference to local variable 'tmp' returned
Voici le code de la surcharge
const Int& Int::operator+(const Int& p) const
{
Int tmp = value + p.value;
return tmp;
}
ici est la classe
class Int{
int value;
public:
Int() {} // default constructor
Int(int v) : value(v) {}
Int& operator=(const Int&);
const Int& operator+(const Int&) const;
};