C++ Programming - Objects and Classes - Discussion

Discussion Forum : Objects and Classes - General Questions (Q.No. 3)
3.
Which of the following statement is correct regarding destructor of base class?
Destructor of base class should always be static.
Destructor of base class should always be virtual.
Destructor of base class should not be virtual.
Destructor of base class should always be private.
Answer: Option
Explanation:
No answer description is available. Let's discuss.
Discussion:
15 comments Page 2 of 2.

Nagnath said:   1 decade ago
Because the initialization of base class objects must not be destroyed by deleting object of derived class. That is base class destructor must not be called upon calling derived class destructor.

Abhishek Singh said:   1 decade ago
If object of derived class is created, then constructor of derived class is called automatically, and if base class constructor has same name, then it is called also.

Same scenario will be happened if Destructor of base class is not virtual.
so it should always be virtual.

Abhishek Singh said:   1 decade ago
If object of derived class is created, then constructor of derived class is called automatically, and if base class constructor has same name, then it is called also.

Same scenario will be happened if Destructor of base class is not virtual.

Naseem asraf said:   1 decade ago
Because the initialization of base class objects must not be destroyed by deleting object of derived class. That is base class destructor must not be called upon calling derived class destructor.

Ashish said:   1 decade ago
Because the initialization of base class objects must not be destroyed by deleting object of derived class. That is base class destructor must not be called upon calling derived class destructor.


Post your comments here:

Your comments will be displayed after verification.