Answers for "overloading and overriding in c++"

C++
0

function overriding in oop c++

#include<iostream>
using namespace std;
class Base
{
 public:
 virtual void show() // virtual function
 {
  cout << "Base class";
 }
};
class Derived:public Base
{
 public:
 void show()
 {
  cout << "Derived Class";
 }
};

int main()
{
 Base* b;       //Base class pointer
 Derived d;     //Derived class object
 b = &d;	// passing derived class address into base class pointer	
 b->show();     //Late Binding Occurs
}
Posted by: Guest on May-27-2021

Code answers related to "overloading and overriding in c++"

Browse Popular Code Answers by Language