Friday, 31 August 2012

Single Inheritance using C++

#include<iostream.h>
#include<conio.h>
class base
{
protected:int a,b;
public:
void getdata()
{
cout<<"\n Enter A value=";
cin>>a;
cout<<"\n Enter B value=";
cin>>b;
}
};
class derived:public base
{
public:
void putdata()
{
cout<<"\n\n A value="<<a;
cout<<"\n\n B value="<<b;
}
};
void main()
{
derived obj;
clrscr();
cout<<"\n single inheritance:\n";
obj.getdata();
obj.putdata();
getch();
}

No comments:

Post a Comment

There was an error in this gadget