2:23 PM
Program for concept of inheritance using addition of two numbers in c++

Develop a program for concept of inheritance using addition of two numbers in c++  (in dev c++)

 
#include<iostream>
#include<conio.h>
using namespace std;
class d;
class b
{
int a;
public:
int b;
void get()
{
cout<<"please enter two no."<<endl;
cin>>a>>b;
}
void show()
{
cout<<a<<endl<<b<<endl;
}
int avi()
{
return a;
}
};
class d:public b
{
public:
 
void sum()
{
cout<<avi()+b;//cant direct use private member
}
};
main()
{
//b b1; cant use base operator here
//b1.get();// cant assign using base operator
d d1;
d1.get();
d1.show();
d1.sum();
getch();
}
 
 
output:
 
please enter two no.
5
4
result is
9
Views: 135 | Added by: vijoriya | Tags: Addition, program, c++, Concept, inheritance, Numbers | Rating: 0.0/0
Total comments: 0
avatar