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.

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.

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.

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?

GURIYA said:   1 decade ago
Because constructor is not contained Virtual method table in memory.

Keerthana said:   1 decade ago
What happens if destructor is not virtual?


Post your comments here:

Your comments will be displayed after verification.