• 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: warning: class 'xxx' has virtual functions but non-virtual destructor
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: warning: class 'xxx' has virtual functions but non-virtual destructor


  • Subject: Re: warning: class 'xxx' has virtual functions but non-virtual destructor
  • From: GoochRules! <email@hidden>
  • Date: Mon, 5 Jan 2004 17:28:57 -0700

On Jan 05, 2004, at 16:59, Kevin Hoyt wrote:

I'm getting this warning:
class 'xxx' has virtual functions but non-virtual destructor

This warning is correct, but what does it really mean?  What are the
gotchas to having a class with virtual functions and a non-virtual
destructor?

Scott Meyers, Bjarne Stroustrup, et. al. have provided much better explanations in their various tomes, but simply, if you don't use a virtual destructor, you can't be sure that your base object gets properly destroyed. f or instance:


class a {};
class b : a {};

a* pa = new b;
delete a; // if a::~a isn't virtual, b::~b won't be called.


Suffice to say, you should always have a virtual destructor; and I believe that C++200x (i.e., the next version of the C++ standard) will specify this as a default.


--Matthew Peltzer
_______________________________________________
xcode-users mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/xcode-users
Do not post admin requests to the list. They will be ignored.

References: 
 >warning: class 'xxx' has virtual functions but non-virtual destructor (From: Kevin Hoyt <email@hidden>)

  • Prev by Date: Re: Simple Xcode CVS question
  • Next by Date: Re: warning: class 'xxx' has virtual functions but non-virtual destructor
  • Previous by thread: Re: warning: class 'xxx' has virtual functions but non-virtual destructor
  • Next by thread: Re: warning: class 'xxx' has virtual functions but non-virtual destructor
  • Index(es):
    • Date
    • Thread