#include <iostream>
using namespace std;
class base
{
protected:
int x;
public:
void getdata1()
{
cout << "Enter the value of x = ";
cin >> x;
}
};
class derive: public base
{
private:
int y;
public:
void getdata2()
{
cout << "Enter the value of y = ";
cin >> y;
}
void product()
{
cout << "Product = " << x * y;
}
};
int main()
{
derive a;
a.getdata1();
a.getdata2();
a.product();
return 0;
}
Note: Need to be arranged in compiler after copied
OutPut:
Enter the value of x = 10
Enter the value of y = 20
Product = 200
Enter the value of y = 20
Product = 200