CPP
cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#include <iostream>
using namespace std;
class base
{
public:
base() {cout << "Base ctor\n";}
~base() {cout << "Base dtor\n";}
virtual void show(){}
};
class derived : public base
{
public:
derived() {cout << "derived ctor\n";}
~derived() {cout << "derived dtor\n";}
};
int main() {
base* p = new derived;
delete p;
return 0;
}
Enter to Rename, Shift+Enter to Preview
OUTPUT
Run