I was doing some practicing with pointers to derived classes and when I ran the code provided underneath,the output I get is
Constructor A
Constructor B
Destructor A
Could someone tell me why is B::~B() not getting invoked here?
class A {
public:
A() { std::cout << "Constructor A\n"; }
~A() { std::cout << "Destructor A\n"; }
};
class B : public A {
public:
B() { std::cout << "Constructor B\n"; }
~B() { std::cout << "Destructor B\n"; }
};
int main() {
A* a = new B;
delete a;
}