When destructors are called?

Kim Trang

New member
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 mentioned
 
Answer: d
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.
 

Tìm kiếm

Back
Top