C++ program for Single Inheritance

#include<iostream.h>
#include<conio.h>
class m{
protected:
int m;
public:
m(){
m=10;
}
};
class n:public m{
protected:
int n;
public:
n(){
n=20;
}
void showmn();
};
void n::showmn(){
cout<<"M = "<<m<<endl<<"N = "<<n<<endl;
}
void main(){
clrscr();
n obj;
obj.showmn();
getch();
}

Comments

Popular posts from this blog

OOPs using C++ Language Topics Covered

IMP Questions of OOPS using CPP