208k views
5 votes
Provide examples of the type of program statement that should be placed in a destructor.

User Cephalopod
by
7.9k points

1 Answer

3 votes

Answer:

Step-by-step explanation:

A destructor is called when there is a need to destruct or delete the object that is already created. As a Constructor is used to create an object, similarly a destructor is used to destruct the object. As there will be a default Constructor which is called when creating a new object, the default destructor is called to Destruct the object when the object goes out of scope or the function ends or program ends or a block containing that particular local variable ends or a delete operator is called.Examples for the destructor are (as the destructor contains delete operators )

Examples : delete []s ; In this example when the destructor is called, the delete operator will be called and the object created destructs.

User Irpbc
by
8.3k points