#include <iostream>
class Raman
{
public:
float acres = 21;
float lakh = 60;
void display() { std::cout << "acres: " << acres << "; " << "lakh: " << lakh << "\n"; }
};
class Son : protected Raman
{
public:
Son()
{
acres /= 3;
lakh /= 3;
}
void display() { std::cout << "Son:" << "\n"; Raman::display(); }
};
class Grandson :protected Son
{
public:
Grandson()
{
acres /= 2;
lakh /= 2;
}
void display() { std::cout << "Grandson:" << "\n"; Raman::display(); }
};
int main()
{
Raman raman;
std::cout << "Raman" << "\n";
raman.display();
Son son1, son2, son3;
son1.display();
son2.display();
son3.display();
Grandson grandson1_1, grandson1_2, grandson2_1, grandson2_2, grandson3_1, grandson3_2;
grandson1_1.display();
grandson1_2.display();
grandson2_1.display();
grandson2_2.display();
grandson3_1.display();
grandson3_2.display();
}
Comments
Leave a comment