samedi 23 décembre 2017

Assigning reference returned from method to variable

class A{
/.../
};

class B{
  public:
    A& foo()
    {
       A *bar = new A;
       return *bar;
     }
};

int main()
{
   A varA;
   B varB;
   varA = varB.foo();
   return 0;
}

What will happen when this line is executed varA = varB.foo() ? Will after copy/move assignment operator function call destructor for object created in foo be called?

Aucun commentaire:

Enregistrer un commentaire