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

Annonymous said:   1 decade ago
@Abc.

Explicitly means we have to delete manually.

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

Krunal said:   1 decade ago
No.

Because compiler does not provide any default constructor when we provided explicitly.

Sai said:   1 decade ago
Can constructors be virtual?

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

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

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

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

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.

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


Post your comments here:

Your comments will be displayed after verification.