Re: Delete a class with multiple inheritance through base pointer?

From: Chris Theis (Christian.Theis_at_nospam.cern.ch)
Date: 02/12/04


Date: Thu, 12 Feb 2004 12:23:41 +0100


"Ian" <noone@nowhere.com> wrote in message
news:402B3CCB.6040308@nowhere.com...
> John Harrison wrote:
> > "Ian" <noone@nowhere.com> wrote in message
> > news:402B2AFC.9010906@nowhere.com...
> >
> >>I left out the virtual destructors in A and B...
> >>
> >>Should work, but I am seeing problems where it does not.
> >>
> >
> >
> > What problems are you seeing?
> >
> What I think is a compiler bug.... Members of one base being invalid in
> the destructor of the derived class.
>

Could you elaborate on that (probably with some sample code & which compiler
you're using). From your code I do not see a problem (with the virtual
declartions being added) as the order of destruction is simply the reverse
order of construction. Thus the dtor of the derived class is called before
the one of the base class.

Regards
Chris



Relevant Pages

  • Re: interface programming
    ... make the destructor virtual, and making it pure is no great shakes, ... class IMyClass { ... or otherwise (beyond a trivial one provided by the compiler, ... derived class, ...
    (microsoft.public.vc.stl)
  • Re: auto_ptr compile error
    ... delete statement from destructor of auto_ptr requires the declaration of destructor of wrapped object? ... it leaks sometimes. ... Owner is a class that owns an instance of Thing. ... If you take a closer look, there was actually a compiler warning about it, but no error. ...
    (microsoft.public.vc.language)
  • Re: VB vs. C# language challenge question
    ... then there is no need for an interface definition. ... not having the compiler catch this can lead to disaster. ... have the same error of omission if you only decide to implement the ... to implement the interface in the derived class. ...
    (microsoft.public.dotnet.framework)
  • Re: Virtual dtor and placement new.
    ... templatevoid CallDestructor(T*p) instead of void * helps the ... > could then store a pointer to the original memory and call MyDelete ... The functor is a good solution, but then you don't call the destructor ... unwinded by the compiler. ...
    (comp.lang.cpp)
  • gcc knows about malloc()
    ... The gcc compiler treats malloc() specially! ...
    (comp.lang.c)