#include #define msg(m) cout << m << endl class Objet { int a; public: Objet() : a(-1) { msg("Objet::Objet()"); }; Objet(int v) : a(v) { msg("Objet::Objet(" << a << ")"); }; Objet(const Objet& o) : a(o.a) { msg("Objet::Objet(Objet(" << a << "))"); }; ~Objet() { msg("Objet::~Objet(" << a << ")"); }; public: Objet& operator=(const Objet& o) { msg("Objet(" << a << ") = Objet(" << o.a << ")"); a = o.a; return *this; }; Objet operator+(const Objet& o) { return Objet(a+o.a); }; }; Objet fonc1(Objet o) { return o+o; }; Objet& fonc2(Objet& o) { o = o+o; return o; }; int main () { msg("---"); Objet o1 = Objet(1); msg("---"); Objet o2; msg("---"); Objet o3 = o1+o2; msg("---"); o3 = o1+o2; msg("---"); o3 = fonc1(o1); msg("---"); o3 = fonc2(o2); msg("---"); };