Virtual destructor necessity 1
What is the behavior of the following code?
#include <iostream>
struct Base {
~Base() { std::cout << "Base"; }
};
struct Derived : Base {
~Derived() { std::cout << "Derived"; }
};
int main() {
Base* p = new Derived();
delete p;
}
Sign in to answer questions and track your progress
Sign In