#include class Wilma { protected: void fredCallsWilma() { std::cout << "Wilma::fredCallsWilma()\n"; wilmaCallsFred(); } virtual void wilmaCallsFred() = 0; // A pure virtual function public: void WilmaShops() { std::cout << "Wilma:ChargeIt!" << std::endl; } }; class Fred : protected Wilma { public: void barney() { std::cout << "Fred::barney()\n"; Wilma::fredCallsWilma(); WilmaShops(); } protected: virtual void wilmaCallsFred() { std::cout << "Fred::wilmaCallsFred()\n"; } }; int main() { Fred frd; frd.barney(); // frd.WilmaShops(); //this is illegal ((Wilma&)frd).WilmaShops(); // this works but will not work in private inheritance Wilma &wm = frd; wm.WilmaShops(); return 0; }