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?
Discussion:
3 comments Page 1 of 1.
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.
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.
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.
So it will destroy the objects in reverse order of object created in the program.
Lakshmi prasanna thota said:
9 years ago
Thanks for the clarification @Ishwar.
Post your comments here:
Quick links
Quantitative Aptitude
Verbal (English)
Reasoning
Programming
Interview
Placement Papers