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

12y ago

What else can I help you with?

Related Questions

What is friendly in c plus plus?

The keyword "friend" allows a function or variable to have access to a protected member inside a class.


What is the difference between constructor and friend function in c plus plus?

A constructor is a method that fires when the object is instantiated. A friend function is a function that has special access to the object. They are two different types of things, and cannot be further differenced.


What is the difference between private stafford and plus student loans?

What is the difference between private stafford and plus student loans?


What is the difference between pointers in c and c plus plus?

Nothing.


What is the difference between be plus ing and get plus ing?

There are no such terms in C++.


What is the difference between statements in c plus plus charconstp and char constp?

There is no difference. Both statements are invalid.


What is the difference between plus 8 and -12?

-4


What is the difference between DVD plus r and DVD plus rw?

rightable and rewightable


Difference between void and devoid in c plus plus?

There is no such thing as devoid in C++.


What is difference in photo paper plus glossy and photo paper glossy?

There is no difference between photo paper glossy and plus glossy. The main difference in photo paper can be seen between a matte finish and glossy finish.


What is the difference between Matiz Se and Se plus and that about the safety?

se has not got electric windows like the se plus,otherwise no difference.


What is difference between plus plus you and you plus plus?

Both ++you and you++ have the same ending result. The variable you is incremented. The difference is that, if you use the combination in a larger expression, then you++ will have the initial value of you, while ++you has the incremented value of you.