#include <iostream>
using namespace std;
class base
{
public:
int x;
void getdata()
{
cout << "Enter value of x= "; cin >> x;
}
};
class derive1 : public base
{
public:
int y;
void readdata()
{
cout << "\nEnter value of y= "; cin >> y;
}
};
class derive2 : public derive1
{
private:
int z;
public:
void indata()
{
cout << "\nEnter value of z= "; cin >> z;
}
void product()
{
cout << "\nProduct= " << x * y * z;
}
};
int main()
{
derive2 a;
a.getdata();
a.readdata();
a.indata();
a.product();
return 0;
}
Note: Need to be arranged in compiler after copied
OutPut:
Enter value of x= 20
Enter value of y= 30
Enter value of z= 10
Product= 6000
Enter value of y= 30
Enter value of z= 10
Product= 6000