jeudi 30 mai 2019

Does the both object point to the same value in copy constructor

Foo(const  Container& obj);   // Copy Constructor

Foo::Foo(const Container& obj) : Geom (obj.Geom)  {
 // Assign Values In Constructor
  stdstrContainerName = obj.stdstrContainerName;
  stdstrPluginType = obj.stdstrPluginType;  
}

Foo fooToCopy;
 Foo foo;
 foo = fooToCopy;

1) Since i am using pass by reference do the foo and fooToCopy point to the same variable

2) If fooToCopy goes out of scope before foo than will the variable value be destroyed.

Aucun commentaire:

Enregistrer un commentaire