// File: main3.C // // Testing access to inherited members under private derivation. #include #include #include #include "pd.h" void foo1(Base& b) { b.add1() ; } void foo2(Base* ptr) { ptr->add1() ; } void PrivDer::pdmem() { cout << "\npdmem:" << endl ; print() ; foo1(*this) ; print() ; foo2(this) ; print() ; } void buddy(PrivDer& p) { cout << "\nbuddy:" << endl ; p.print() ; foo1(p) ; p.print() ; foo2(&p) ; p.print() ; } main() { PrivDer P ; P.pdmem() ; buddy(P) ; }