Yes...
So it adds a 4 byte (8 on 64bit) table. big deal
So it adds a few bytes of extra code to deal with this virtual destructor. big deal.
In the big light of things, and with a growing trend for VM's, and intermediate languages. The above will as I stated have little impact on the totality of your program. There are very few cases where that virtual will cause unwanted effects.
FORGETTING the virtual when it was needed otoh. can have significant effects on your program.
Is it ideal. no. but that can be said about a lot of programming habits you do "just in case".
it's also a good habit to initialize every single member variable in your class. Even if you never end up using them. and even when you know that when you will be needing it, you're setting it to a valid value anyway. That's also code wasted. but somewhere down the line maintaining your code, it's a good habit anyway. :)
Even it the class is NOT designed to be a polymorphic base class. If you are making class libraries that other will be using, you are only restricting their possibilities by not doing this.Quote:
Yes, if your class is designed to be a polymorphic base class, then it should either have a virtual destructor that is public, or a non-virtual destructor that is protected. At the same time, if a class has virtual functions, it is likely to be designed to be a polymorphic base class. As such, I find the insistence that such a factor has no relevance at all to be an exaggeration.
For this very same reason, unless you have VERY VERY good reason to, it's probably a bad idea to mark your classes as sealed. You may not see a need to derive further from them, but someone using your classes may have different ideas/needs.
I find it strange you're calling it an exaggeration when it is obviously correct. There IS NO direct correlation between a class having (or not having) virtual functions and the need for a virtual destructor. It is perfectly possible for a class to have no virtual functions at all and yet needing a virtual destructor to function properly. (written and used plenty of them). It is equally possible to have a class with virtual members and NOT needing a virtual destructor because even though the class is used through a base pointer does not imply that it will be deleted through a base pointer.
I will sort of agree that a class with virtual members is a likely candidate for needing a virtual destructor as well (without conclusions about the opposite). But that relation is much much less of a formal rule than than say the relation between a class that has a copy constructor also needing an assign operator (or vice versa).
Heh. :)Quote:
Maybe not but what happens to your dignity? Before you know it you will be programming in Java!
There are worse choices to loose your dignity in.
Either way, I'm happy i don't need to program in java, although I occasionally need to read/review it.

