The derived class does not have access permission to the private member of its base class, and does not have access permission to the protected member of the base class object) private and protected members have access permissions.
Because c ++ has a poor foundation and does not need it at ordinary times, a very critical error is corrected today. The class access permission is for the class, instead of for class objects. I have always understood it wrong. I have no face to write this sentence, but I still want to write it down.
The following is a simple test code. The access permissions of the objects test, basic class parameters, and derived class parameters that call member functions are tested as follows:
# Include <iostream> using namespace STD; class base {public: int pub; protected: int pro; private: int pri ;}; class derive: public base {public: int newpub; protected: int newpro; private: int newpri; public: int func (class base A, class derive B) {/////////////////////////////////////// /// test the cout <newpub <Endl; cout <newpro <Endl; cout <newpri <Endl; cout <pub <Endl; cout <pro <Endl; // No access cout <pri <Endl; //////////////////////////////////////// /test the cout of the base class object access permission <. pub <Endl; // No access cout <. pro <Endl; // No access cout <. PRI <Endl; //////////////////////////////////////// /test cout for the access permissions of the base class and non-base class members of the derived class Object <B. pub <Endl; cout <B. pro <Endl; // No access cout <B. PRI <Endl; cout <B. newpub <Endl; cout <B. newpro <Endl; cout <B. newpri <Endl; //////////////////////////////////////// return 0 ;}}; int main () {class base A; Class derive B; Class derive test; test. func (a, B); Return 0 ;}