Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

void show( ) { cout << \"Name \" << name << endl; } That is the base version of

ID: 3536657 • Letter: V

Question

   void show( )       { cout << "Name " << name << endl; }
That is the base version of show().
It will print the string "Name " followed by the private value of name, whatever it is at that time.
No destructor is involved when calling show().

You call the destructor when you get rid of an object of that class,
typically, at the end of main().

Can anyone explain that further?    void show( )       { cout << "Name " << name << endl; }
That is the base version of show().
It will print the string "Name " followed by the private value of name, whatever it is at that time.
No destructor is involved when calling show().

You call the destructor when you get rid of an object of that class,
typically, at the end of main().

Can anyone explain that further?

Explanation / Answer

destructors are basically used to free the memory, to delete the class objects which are no longer in use hence can be removed and that memory location can be used by othe class objects.