[Solved] C++ – destructors [closed]


Examples

When a variable goes out of scope

void foo()
{
   MyClass C;
   C.callSomeMethod();
}  // C is here going out of scope

or a dynamically allocated variable is
explicitly deleted using the delete
keyword

void foo()
{
  MyClass* C = new MyClass; // allocating on heap
  delete C; // deleting allocated memory
...
}

solved C++ – destructors [closed]