virtual

PHOTO EMBED

Fri Sep 16 2022 06:39:47 GMT+0000 (Coordinated Universal Time)

Saved by @kodekutulisanku #c++

#include<iostream> 
using namespace std; 
class Base { 
public: 
  Base() {
    cout << "Constructing Base \n";
  } 
  virtual~Base() {
    cout << "Destructing Base \n";
  }	 
}; 
class Derived: public Base { 
public:
  Derived() {
    cout << "Constructing Derived \n";
  } 
  ~Derived() {
    cout << "Destructing Derived \n";
  } 
}; 
 
int main(void) 
{ 
	Derived *d = new Derived(); 
	Base *b = d; 
	delete b; 
	return 0; 
}
content_copyCOPY