C
Christian Hackl
Does the following code produce undefined behaviour?
class Base
{
public:
virtual ~Base();
/* ... */
};
class BaseWithNonVirtualDestructor
{
protected:
~BaseWithNonVirtualDestructor();
/* ... */
}
class Derived : public Base, public BaseWithNonVirtualDestructor
{
public:
/* ... */
};
int main()
{
Base *ptr = new Derived;
delete ptr;
}
May you also point me to the section of the standard which defines the
behaviour of such MI constructs in conjunction with virtual destructors?
For my current problem, by the way, BaseWithNonVirtualDestructor is
actually boost::noncopyable, which I would like to use in this manner.
class Base
{
public:
virtual ~Base();
/* ... */
};
class BaseWithNonVirtualDestructor
{
protected:
~BaseWithNonVirtualDestructor();
/* ... */
}
class Derived : public Base, public BaseWithNonVirtualDestructor
{
public:
/* ... */
};
int main()
{
Base *ptr = new Derived;
delete ptr;
}
May you also point me to the section of the standard which defines the
behaviour of such MI constructs in conjunction with virtual destructors?
For my current problem, by the way, BaseWithNonVirtualDestructor is
actually boost::noncopyable, which I would like to use in this manner.