In my following function a new Object of MyClass
is created and assingned to myObject
. After that the destructor of the new Object is called. The original object declared in outside the function is NOT destroyed. MyClass
has the dafault assignement operator.
MyClass myObject; //global varibale;
void somefuction()
{
myObject = MyClass();
}
My Question is: Is there a way to store a new object in myObject
, so that the orginal object is destroyed, without using pointers.