0
When does the destructor called in the program?
destructor destroy the program.
2 Réponses
+ 22
we use it to destroy or delete an object
https://www.sololearn.com/learn/CPlusPlus/1875/?ref=app
+ 3
For C++, a destructor is called in 2 cases I can think of:
1. if you defined an object within a block, i.e. within a pair of {}, then it is deleted when it goes out of scope at the end of the brace. such object are allocated on the stack.
2. If you explicitly defined it by using the 'new' operator, it will get deleted when you explicitly call the 'delete' operator. Such objects are allocated off the heap.