Introducing Radical.sh

Forget Code launches a powerful code generator for building API's

Single Inheritance in C++

#include<iostream.h>
#include<conio.h>
class B
{public:
int a,b;
void get();
void show();
};
class D:public B
{int c;
public:
void mul();
void disp();
};
void B::get()
{a=5;
b=10;
}void B::show()
{cout<<"\t"<<a;}
void D::mul()
{c=b*a;
}void D::disp()
{cout<<"\n"<<a<<"\t"<<b<<"\ta*b:"<<c;
}void main()
{D d;
clrscr();
d.get();
d.mul();
d.show();
d.disp();
d.b=20;
d.mul();
d.disp();
getch();
}