D
david
Here is the code:
class B {
public:
virtual ~B() {};
};
class D : public B {
public:
D() { t = new int; }
~D() { delete t; }
private:
int* t;
};
void do_something()
{
B* pb = static_cast<D*> (new D());
// do something ...
delete pb;
}
My question is whether the D class' destructor is called? What happen
when I use the static_cast? Thanks in advance.
class B {
public:
virtual ~B() {};
};
class D : public B {
public:
D() { t = new int; }
~D() { delete t; }
private:
int* t;
};
void do_something()
{
B* pb = static_cast<D*> (new D());
// do something ...
delete pb;
}
My question is whether the D class' destructor is called? What happen
when I use the static_cast? Thanks in advance.