Re: C++: std::ostringstream default ctor problems
Re: C++: std::ostringstream default ctor problems
- Subject: Re: C++: std::ostringstream default ctor problems
- From: Rippit the Ogg Frog <email@hidden>
- Date: Mon, 28 Sep 2009 10:58:42 -0700
Rush Manbert wrote:
By any chance is the foobar class a derived class? And, if so, does its
base class NOT have a virtual destructor?
In general a non-virtual destructor should be taken as a signal that a
class is NOT to be derived from.
You can make it work if you try, but it's almost always a mistake to
derive from a class with a non-virtual destructor.
In Java they have the "final" keyword for this.
It will work to have a virtual destructor on a class that is never
derived from, but it will be a very small performance hit when the
destructor is called. Whether that matters depends on how often the
destructor is called.
I don't think this is as well-understood as it should be; some naive
coders will either make everything virtual, or nothing virtual without
any understanding of what needs to be virtual or what shouldn't be.
Similarly if a member function in a base class is not meant to be
overridden, don't make it virtual. But if it is meant to be overridden,
always make it virtual.
--
Rippit the Ogg Frog
email@hidden
http://www.oggfrog.com/
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden