I'm having trouble creating a B1 reference to d1. I get a compiler error saying "error C2243: 'type cast' : conversion from 'D1 *' to 'B1 &' exists, but is inaccessible". Somehow I got it to compile by making D1 a struct. I'm using Visual C++.
Code:#include "../std_lib_facilities.h" class B1 { public: virtual void vf() {cout << "B1::vf\n";} void f() {cout << "B1::f\n";} }; class D1 : B1 { public: void vf() {cout << "D1::vf\n";} void f() {cout << "D1::f\n";} }; int main() { B1 b1; D1 d1; b1.vf(); b1.f(); d1.vf(); d1.f(); B1& r = d1; keep_window_open(); }



LinkBack URL
About LinkBacks



