class Base
{
virtual void foo() = 0;
//~Base(); <-- No destructor!
};
Obviously, Base will be derived. So, does C++ says the compiler-generated destructor of Base must be virtual?
Thanks!
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
No, the destructor will not be
virtualunless you mark it as such. The reason is simple – calls can be made virtually both via pointers and via references and how and whether you make calls virtually is unrelated to whether you create objects withnew. If you don’t create objects withnewyou don’t have todeletethem and so you don’t need virtual destructors.