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 1 of 2.

Chandu reddy said:   6 years ago
What is the difference between pure virtual and absult virtual class?
(2)

Shaan said:   1 decade ago
Because if we assign derived class in to base class pointer then if we call delete then only base class destructor will call, base class destructor will not call.

So object will not fully destroy. And now if the destructor of base class is virtual then derived class destructor will call and object will fully destroy.
(1)

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.

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.

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.

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.

Neha said:   1 decade ago
Because, the initialization of base class object must not be destroyed by deleting object of derived class. That is base class.

Destructor must not be called upon calling derived class destructor.

Ajay said:   1 decade ago
why we use concept of virtual?

Shalin said:   1 decade ago
Why constructor can not be created virtual?


Post your comments here:

Your comments will be displayed after verification.