• 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: Xcode UI questions
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Xcode UI questions


  • Subject: Re: Xcode UI questions
  • From: Andreas Grosam <email@hidden>
  • Date: Thu, 8 Sep 2005 14:23:07 +0200


On 08.09.2005, at 12:52, Jonathan Taylor wrote:

Thanks to the people who answered my last set of questions about Xcode. I wonder if I could try a few more...

I've been experimenting with all the warnings that gcc can provide - and it's picked up a few lurking bugs in my codebase. I'm a bit confused by the "Nonvirtual Destructor" warning, though. It warns me when _no_ destructor or constructor is defined at all for a class. Is it right to flag that as a problem? The explanation for the warning flag says "warn when a class _declares_ a nonvirtual destructor", which if interpreted literally doesn't seem to cover this case. Is it risky to not declare any destructor at all for a superclass, or is gcc being over-zealous in its warnings?
This is a *warning* only!
If this warning is enabled, gcc will warn you when you have a class with at least one virtual function but with no virtual destructor defined.

However, it depends on the context if a *non-virtual* d-tor might become a problem or not (see note below).
You need to declare a destructor explicitly *virtual* in a base class, if you call the destructor polymorphically:
class Base {
public:
virtual ~Base() {}
};
class Derived : public Base
{};

Base* b = new Derived();
delete b; // !!! in this case you need a virtual destructor!

Note: gcc, and all other compliant C++ compilers, generate code for certain c-tors, d-tors and operators automatically, if not explicitly defined. However, these will be generated in the *default* way - means, for instance, the destructor is puplic and non-virtual.

Andreas

<snip>
Cheers
Jonny _______________________________________________
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
 _______________________________________________
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: 
 >Xcode UI questions (From: Jonathan Taylor <email@hidden>)

  • Prev by Date: Re: XCode Rules!
  • Next by Date: Re: Xcode UI questions
  • Previous by thread: Xcode UI questions
  • Next by thread: Re: Xcode UI questions
  • Index(es):
    • Date
    • Thread