#include <iostream>
using std::cout;
using std::endl;
class Base {
protected:
int a, b;
public:
void set_ab(int _a, int _b) {
a = _a;
b = _b;
}
void print_base() {
cout << a << " " << b << endl;
}
};
class Derived1 : public Base {
int c;
public:
void set_c(int _c) {
c = _c;
}
void print_derived1() {
cout << c << endl;
}
};
class Derived2 : public Derived1 {
int d;
public:
void set_d(int _d) {
d = _d;
}
void print_derived2() {
cout << d << endl;
}
};
int main()
{
Derived1 od1;
od1.set_ab(15, 18);
od1.print_base();
od1.set_c(23);
od1.print_derived1();
Derived2 od2;
od2.set_ab(867, 999);
od2.print_base();
od2.set_c(725);
od2.print_derived1();
od2.set_d(189);
od2.print_derived2();
return 0;
}
/*
run:
15 18
23
867 999
725
189
*/