On 22 Apr., 04:43, internetpet <internet...@[EMAIL PROTECTED]
> wrote:
> BigClazz.h
>
> class Clazz; // Note the forward declaration only , no include
> "Clazz.h"
> class BigClazz
> {
> public:
> BigClazz();
> ~BigClazz();
> Clazz* pclazz;
> };
>
> BigClazz.cpp
>
> #include "BigClazz.h"
> BigClazz::BigClazz(){}
> BigClazz::~BigClazz()
> {
> delete pclazz; // Here the destructor of of the Clazz object
> will not be called
> }
You are violating the constraints of Our Holy Standard here:
[expr.delete]/5: "If the object being deleted has incomplete class type
at the point of deletion and the complete class has a non-trivial
destructor
or a deallocation function, the behavior is undefined."
> #include "Clazz.h"
> Clazz::Clazz(){};
> Clazz::~Clazz(){};
This is a user-defined d'tor, therefore it is non-trivial according to the
standard, [class.dtor]/3+4:
"If a class has no user-declared destructor, a destructor is declared
implicitly.
An implicitly-declared destructor is an inline public member of its class.
A
destructor is trivial if it is an implicitly-declared destructor and [..]
Otherwise, the destructor is non-trivial."
HTH & Greetings from Bremen,
Daniel Krügler
--
[ See http://www.gotw.ca/resources/clcm.htm
for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]


|