#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 : private Wilma { public: void barney() { std::cout << "Fred::barney()\n"; Wilma::fredCallsWilma(); } protected: virtual void wilmaCallsFred() { std::cout << "Fred::wilmaCallsFred()\n"; WilmaShops(); } }; int main() { Fred frd; frd.barney(); // frd.WilmaShops(); this is illegal // this works ((Wilma&)frd).WilmaShops(); // this is illegal //Wilma &wm = frd; //wm.WilmaShops(); Wilma *wm; // this is also illegal //try { // wm = &frd; //} catch (...) { // wm = (Wilma *)&frd; //wm = dynamic_cast( &frd); //wm = const_cast( &frd); // these all will work wm = reinterpret_cast( &frd); void *foo = reinterpret_cast( &frd); wm = reinterpret_cast( foo); return 0; }