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!
No, the destructor will not be virtual
unless 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 with new
. If you don't create objects with new
you don't have to delete
them and so you don't need virtual destructors.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With