conversion to inaccessible base class is not allowed [duplicate]
问题 This question already has answers here : C++ inheritance - inaccessible base? (2 answers) Closed 3 years ago . I define a class B1 and a derived class D1 at first. Then I want to define a reference to B1 and initialize that to the D1 object I just defined. Here comes the error, saying that "conversion to inaccessible base class 'B1' is not allowed", which I don't know why. #include "std_lib_facilities.h" class B1 { public: virtual void vf() { cout << "B1::vf()\n"; }; void f() { cout << "B1::f