IGNOU, SMU and KSOU Bsc solved assignments – C++ program to demonstrate Virtual Functions

IGNOU, SMU and KSOU Bsc solved assignments – C++ program to demonstrate Virtual Functions

If you are BSc IT, Btech C/S, Msc computer science or Bsc computer science students and looking for solved assignments on C++ here is proper solution.

Below C++ program is for   to demonstrate Virtual Functions. It is solved assignment for IGNOU, SMU and KSOU Bsc IT or Computer science students

// Program to demonstrate Virtual Functions.

#include<iostream.h>
#include<conio.h>

class Base
{
public : void display()
{
cout<<”\n Display Base. “;
}
virtual void show()
{
cout<<”\n Show Base. “;
}
};

class Derived : public Base
{
public : void display()
{
cout<<”\n Display Derived. “;
}
void show()
{
cout<<”\n Show Derived. “;
}
};

void main()
{
clrscr();

Base b;
Derived d;
Base *bptr;

bptr=&b;
bptr->display();
bptr->show();

bptr=&d;
bptr->display();
bptr->show();

getch();
}

All New Updates

Leave a Reply

Your email address will not be published. Required fields are marked *

Security Code: