C++ Programming - Constructors and Destructors - Discussion

Discussion Forum : Constructors and Destructors - General Questions (Q.No. 29)
29.
Destructor calls are made in which order of the corresponding constructor calls?
Reverse order
Forward order
Depends on how the object is constructed
Depends on how many objects are constructed
Answer: Option
Explanation:
No answer description is available. Let's discuss.
Discussion:
3 comments Page 1 of 1.

Ramya said:   1 decade ago
The constructor are called as in the order of objects creation. But Destructor calls when the objects is going to destroy.

So it will destroy the objects in reverse order of object created in the program.

Ishwar said:   10 years ago
Destructor are called in reverse order i.e if we have base class and derived class then first during constructor call base class constructor is called then derived class constructor call happen, but in case of destructor first derived destructor called then base class destructor call happen.

This is why because derived class pointer can't point to base class member so if first base class destructor is called then we are unable to use base class.

Lakshmi prasanna thota said:   9 years ago
Thanks for the clarification @Ishwar.

Post your comments here:

Your comments will be displayed after verification.