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.

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?

Divya Agrawal said:   10 years ago
But how destructor uses virtual? It is not getting.

Gaurav said:   9 years ago
There is no need to use destructor as virtual because the principle of destructor is to delete the constructor and free the memory allocated by constructor and virtual function should transfer the function call from base class to derive i.e. if want to delete the constructor of both the classes but the can't happen it should be delete only derived class object.

Sumit sharma said:   9 years ago
Significance of virtual function is to provide late binding by restricting the early binding. So destructor should be always virtual so respective descended class's destruction execute instead of parent class destructior, when accesed through pointer as a refrence of the oblect.


Post your comments here:

Your comments will be displayed after verification.