Re: inhibit compiler warning C4624 for a class hierarchy
- From: "Ben Voigt" <rbv@xxxxxxxxxxxxx>
- Date: Wed, 10 Jan 2007 13:05:25 -0600
"Igor Tandetnik" <itandetnik@xxxxxxxx> wrote in message
news:eERgQSNNHHA.1240@xxxxxxxxxxxxxxxxxxxxxxx
Ben Voigt <rbv@xxxxxxxxxxxxx> wrote:Non-virtual destruction from the base class doesn't use this
Every instance will be
freed by the base class destructor and operator delete, regardless of
specific type.
It doesn't work this way. Any class must have a destructor before you can
create (or, to be exact, destroy) an instance of it. It could be trivial,
it could be private, it could be implicitly defined, but a class must have
one. From the standard:
12.4/5 An implicitly-declared destructor is implicitly defined when it is
used to destroy an object of its class type (3.7). A program is
implicitly-declared destructor, so this rule doesn't apply.
ill-formed if the class for which a destructor is implicitly defined has:
...
- a base class with an inaccessible destructor.
The moment you use delete on the pointer of the derived type (whether in
the base class or otherwise) your program becomes ill-formed.
--
With best wishes,
Igor Tandetnik
With sufficient thrust, pigs fly just fine. However, this is not
necessarily a good idea. It is hard to be sure where they are going to
land, and it could be dangerous sitting under them as they fly
overhead. -- RFC 1925
.
- Follow-Ups:
- Re: inhibit compiler warning C4624 for a class hierarchy
- From: Igor Tandetnik
- Re: inhibit compiler warning C4624 for a class hierarchy
- References:
- inhibit compiler warning C4624 for a class hierarchy
- From: Ben Voigt
- Re: inhibit compiler warning C4624 for a class hierarchy
- From: Alex Blekhman
- Re: inhibit compiler warning C4624 for a class hierarchy
- From: Heinz Ozwirk
- Re: inhibit compiler warning C4624 for a class hierarchy
- From: Alex Blekhman
- Re: inhibit compiler warning C4624 for a class hierarchy
- From: Ben Voigt
- Re: inhibit compiler warning C4624 for a class hierarchy
- From: Igor Tandetnik
- inhibit compiler warning C4624 for a class hierarchy
- Prev by Date: Re: Creating thread from a class object
- Next by Date: Check internet connection
- Previous by thread: Re: inhibit compiler warning C4624 for a class hierarchy
- Next by thread: Re: inhibit compiler warning C4624 for a class hierarchy
- Index(es):
Relevant Pages
|