Thanks to visit codestin.com
Credit goes to www.scribd.com

0% found this document useful (0 votes)
9 views1 page

Experiment No 7

The document presents a C++ program demonstrating polymorphism through virtual functions. It defines a base class 'A' with a virtual method 'show' and a derived class 'B' that overrides this method. In the main function, a pointer of type 'A' is used to call the 'show' method of an object of class 'B', illustrating dynamic binding.

Uploaded by

gmranuj
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views1 page

Experiment No 7

The document presents a C++ program demonstrating polymorphism through virtual functions. It defines a base class 'A' with a virtual method 'show' and a derived class 'B' that overrides this method. In the main function, a pointer of type 'A' is used to call the 'show' method of an object of class 'B', illustrating dynamic binding.

Uploaded by

gmranuj
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 1

// Experiment No.

7 - Polymorophism – Virtual function

#include<iostream>

using namespace std;

class A

public:

virtual void show()

cout<<"\n Base Class";

};

class B:public A

public:

void show()

cout<<"\n Derived Class";

};

int main()

A *bptr;

B aa;

bptr=&aa;

bptr->show();

return 0;

You might also like