Friday 29 September 2017

Simple Virtual Base Class program in C++


#include<iostream>
#include<stdio.h>
using namespace std;
class one
{
public:
int a,b,c;
virtual void get(int x1)
{
a=x1;
cout<<"CLASS ONE";
}
};
class three: public one
{
protected:
int p,q,r;
public:
void get(int r1)
{
q=r1;
cout<<"CLASS THREE";
}
};
main()
{
three t;
one *ptr;
ptr=&t;
ptr->get(5);
}

No comments:

Post a Comment

Amazon1Ads