/* ex_5_5.c++ */ #include using namespace std; class A { int i_priv; protected: int i_prot; public: int i_publ; A(); }; A::A() : i_priv(1), i_prot(2), i_publ(3) { cout << "--------" << endl; cout << "A :" << endl; cout << i_publ << endl; cout << i_prot << endl; cout << i_priv << endl; } class B_priv : A { public: B_priv(); }; B_priv::B_priv() { cout << "B_priv :" << endl; cout << i_publ << endl; cout << i_prot << endl; // cout << i_priv << endl; } class B_prot : protected A { public: B_prot(); }; B_prot::B_prot() { cout << "B_prot :" << endl; cout << i_publ << endl; cout << i_prot << endl; // cout << i_priv << endl; } class B_publ : public A { public: B_publ(); }; B_publ::B_publ() { cout << "B_publ :" << endl; cout << i_publ << endl; cout << i_prot << endl; // cout << i_priv << endl; } class C_prot : public B_prot { public: C_prot(); }; C_prot::C_prot() { cout << "C_prot :" << endl; cout << i_publ << endl; cout << i_prot << endl; // cout << i_priv << endl; } class C_priv : public B_priv { public: C_priv(); }; C_priv::C_priv() { cout << "C_priv :" << endl; // cout << i_publ << endl; // cout << i_prot << endl; // cout << i_priv << endl; } int main() { A a; B_publ b_publ; B_prot b_prot; B_priv b_priv; C_prot c_prot; C_priv c_priv; cout << "--------" << endl; cout << "main :" << endl; cout << a.i_publ << endl; cout << b_publ.i_publ << endl; // cout << b_prot.i_publ << endl; // cout << b_priv.i_publ << endl; return 0; }