Sadece bir + operatörünü aşırı yüklemeye çalışıyorum ve bu derleyiciyi uyarıyorumC++ derleyici uyarısı - dönen yerel değişken
reference to local variable 'tmp' returned
İşte
const Int& Int::operator+(const Int& p) const
{
Int tmp = value + p.value;
return tmp;
}
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;
};
class Int{
int value;
public:
Int() {} // default constructor
Int(int v) : value(v) {}
Int& operator=(const Int&);
const Int& operator+(const Int&) const;
};
class Int{
int value;
public:
Int() {} // default constructor
Int(int v) : value(v) {}
Int& operator=(const Int&);
const Int& operator+(const Int&) const;
};