C++ Programming - Constructors and Destructors - Discussion
Discussion Forum : Constructors and Destructors - General Questions (Q.No. 3)
3.
Can a class have virtual destructor?
Discussion:
22 comments Page 2 of 3.
Krunal said:
1 decade ago
No.
Because compiler does not provide any default constructor when we provided explicitly.
Because compiler does not provide any default constructor when we provided explicitly.
ABC said:
1 decade ago
What is the meaning of explicitly call?
Annonymous said:
1 decade ago
@Abc.
Explicitly means we have to delete manually.
Explicitly means we have to delete manually.
Waseem Ahmad Naeem said:
1 decade ago
If an object goes out of scope destructor is called automatically then why we need to call it explicitly?
Arun said:
9 years ago
What happens when a virtual function is declared as static?
Amit said:
9 years ago
Virtual destructors are used to delete memory allocated for derived class. By default the destructor deletes memory just for base class.
Shikha Singh said:
8 years ago
@Arun
No, because it doesn't make any sense in C++.
Virtual functions are invoked when you have a pointer/reference to an instance of a class.
Static functions aren't tied to a particular instance, they're tied to a class.
C++ doesn't have pointers-to-class, so there is no scenario in which you could invoke a static function virtually.
No, because it doesn't make any sense in C++.
Virtual functions are invoked when you have a pointer/reference to an instance of a class.
Static functions aren't tied to a particular instance, they're tied to a class.
C++ doesn't have pointers-to-class, so there is no scenario in which you could invoke a static function virtually.
Gopika said:
8 years ago
What is meant by the term warping functions associated with virtual destructors?
Amir Sandila said:
8 years ago
What is meant by virtual?
Ankit said:
7 years ago
Why is virtual constructor not possible? Please explain.
Post your comments here:
Quick links
Quantitative Aptitude
Verbal (English)
Reasoning
Programming
Interview
Placement Papers