1#include<iostream>
2using namespace std;
3class Base
4{
5 public:
6 virtual void show() // virtual function
7 {
8 cout << "Base class";
9 }
10};
11class Derived:public Base
12{
13 public:
14 void show()
15 {
16 cout << "Derived Class";
17 }
18};
19
20int main()
21{
22 Base* b; //Base class pointer
23 Derived d; //Derived class object
24 b = &d; // passing derived class address into base class pointer
25 b->show(); //Late Binding Occurs
26}