Find The Addition Of Two Number Using Inheritance Programing In C++
#include <iostream.h>
#include <conio.h>
class base //single base class
{
public:
int x;
void getdata()
{
cout << "Enter the value of x = ";
cin >> x;
}
};
class derive : public base //single derived class
{
private:
int y;
public:
void readdata()
{
cout << "Enter the value of y = ";
cin >> y;
}
void product()
{
cout << "Product = " << x * y;
}
};
void main()
{
derive a; //object of derived class
a.getdata();
a.readdata();
a.product();
getch();
} //end of program
Thank You....!!!
0 Comments