C++ Programming - Constructors and Destructors - Discussion

Discussion Forum : Constructors and Destructors - General Questions (Q.No. 3)
3.
Can a class have virtual destructor?
Yes
No
Answer: Option
Explanation:
No answer description is available. Let's discuss.
Discussion:
22 comments Page 1 of 3.

Padma said:   1 decade ago
How the destructor can be a virtual ?

Swami vivekanand L. said:   1 decade ago
Destructor can be virtual because whenever the object goes in out of the scope then we have to delete it explicitly i.e. we need to call the destructor explicitly so destructor should made as virtual destructor like same as virtual function.

Surya.T said:   1 decade ago
What is mean by virtual function?

Nishant Singh said:   1 decade ago
Virtual functions provide run time polymorphism as the function to be executed is decided at run-time.

Dwarika said:   1 decade ago
Destructor can be virtual because whenever the object goes in out of the scope then we have to delete it explicitly.

Priyanka said:   1 decade ago
But if object goes out of scope, destructor is called automatically. Then why we need to call it explicitly?

KJS said:   1 decade ago
In C++ there is no automatic garbage collection.

Velmurugan said:   1 decade ago
Destructor is invisibility in your program and it's call automatically. Because every constructor program using inside destructor.

Lilly said:   1 decade ago
Please clarify my doubt. Class is declared as virtual then how the class contain destructor?

Sai said:   1 decade ago
Can constructors be virtual?


Post your comments here:

Your comments will be displayed after verification.