Re: inhibit compiler warning C4624 for a class hierarchy
- From: "Igor Tandetnik" <itandetnik@xxxxxxxx>
- Date: Wed, 10 Jan 2007 11:29:54 -0500
Ben Voigt <rbv@xxxxxxxxxxxxx> wrote:
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
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: Ben Voigt
- 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
- inhibit compiler warning C4624 for a class hierarchy
- Prev by Date: Local class in inline function
- Next by Date: Re: Creating thread from a class object
- 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
|
Loading