CPP MCQ
When destructors are called?
A)
When a program ends
B)
When a function ends
C)
When a delete operator is used
D)
All of the above

Correct Answer : Option (D) :   All of the above

Explanation :

Destructors are called at the following time :

i) at the end of the program to destroy objects declared in the main() or global scope.
ii) at the end of a function to destroy objects declared at that function scope.
iii) when user by himself tries to delete an object using the delete operator.
iv) at the end of a block to destroy objects declared at that block scope.