Boost logo

Boost :

From: Hartmut Kaiser (hartmut.kaiser_at_[hidden])
Date: 2008-05-03 16:13:21


> Stefan Seefeld:
> > How do you prevent then any users deriving from your classes, from
> > adding their own destructors ? Their destructors might not be
> invoked,
> > since the base destructor isn't virtual.
>
> How does this look in code?

struct A
{
    ~A() {} // non-virtual
    virtual void foo() {}
};

struct B : A
{
    ~B() {}
    void foo() {}
};

///////////
A* a = new B;
delete a; // doesn't call ~B(), but should

Regards Hartmut


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk