• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: C++: std::ostringstream default ctor problems
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


References: 
 >C++: std::ostringstream default ctor problems (From: Dan Caugherty <email@hidden>)
 >Re: C++: std::ostringstream default ctor problems (From: Rush Manbert <email@hidden>)

  • Prev by Date: Using Xcode for automated daily builds; how do I generate version info?
  • Next by Date: Re: warning at nslog
  • Previous by thread: Re: C++: std::ostringstream default ctor problems
  • Next by thread: Re: C++: std::ostringstream default ctor problems
  • Index(es):
    • Date
    • Thread