Will the template argument's destructor to a templated class be called on deletion?

Posted by Mutmansky on Stack Overflow See other posts from Stack Overflow or by Mutmansky
Published on 2010-05-13T22:17:50Z Indexed on 2010/05/13 22:24 UTC
Read the original article Hit count: 116

Filed under:
|
|

If you have a templated base class as in the following example:

class A{
    A();
    virtual ~A();
};

template <class T>
class B : public T
{
    B();
    virtual ~B();
};

typedef B<A> C;

class D : public C
{
    D();
    virtual ~D();
};

When you delete an instance of D, will the destructor of A be called?

I'll probably create a test program to find out what happens, but just thinking about it, I wasn't sure what should happen.

© Stack Overflow or respective owner

Related posts about c++

Related posts about templates