answersLogoWhite

0

The private, protected and public keywords are used to modify the access specifiers of class or struct members. Unless otherwise specified, class members are private by default, while struct members are public by default.

Private members of a class are only accessible to members and to friends of that class. Protected members are the same as private members, but are also accessible to derived classes. Public members have unrestricted access.

The private, protected and public access specifiers can also be used to modify the type of inheritance that applies to a derived class. Private inheritance means all public and protected members of the base class become private members of the derived class. Protected inheritance means all public members of the base class become protected members of the derived class. Public inheritance means all public and protected members of the base class remain public and protected members of the derived class. Private members of the base class are never inherited by derived classes. A derived class or one or more of its member functions may be declared a friend of the base class, thus permitting private access, but you would never do this unless the hierarchy were a closed, static hierarchy where all derivatives can be determined at compile time. Dynamically bound derivatives of unknown origin cannot be declared friends.

User Avatar

Wiki User

11y ago

What else can I help you with?