A program to show the implementation of Simple Inheritance.

 

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

class base
{
protected:
char a[50];

void getdata()
{
cout<<"Enter string in base class: ";
gets(a);
}
};

class derived : private base
{
public:
void display()
{
getdata();
cout<<"\nString in base class: ";
puts(a);
}
};

void main()
{
clrscr();

derived d;

d.display();

getch();
}

 

< Back