A public class is a base class declared with public inheritance:
class base {
// ...
};
class derived : public base {
// ...
};
In the above example, base is a public class of derived, thus derived is regarded as being a type of base. The derived class inherits all the public and protected methods of its base. Protected methods are accessible to the derived class, its derivatives and their friends.
If base were declared protected, its public methods become protected methods of derived. The base class is then an implementation detail of derived; only members of derived, its derivatives and their friends can treat derived as being a type of base.
If declared private, the public and protected methods of base become private methods of derived. The base class is then an implementation detail of derived; only members of derived and its friends can treat derived as a type of base.
Copyright © 2026 eLLeNow.com All Rights Reserved.