Go4Expert

Go4Expert (http://www.go4expert.com/)
-   C (http://www.go4expert.com/forums/c/)
-   -   a small doubt.please clarify. (http://www.go4expert.com/forums/small-doubtplease-clarify-t5595/)

adroit89 1Aug2007 19:43

a small doubt.please clarify.
 
hi.
i just want to know weather the inherited protected member of base class would be a protected or private member of the inherited class if we inherit in protected way?? :)

DaWei 1Aug2007 20:31

Re: a small doubt.please clarify.
 
Protected.

adroit89 1Aug2007 20:39

Re: a small doubt.please clarify.
 
okk.then in multilevel inheritence can we access the protected member of the base class from a class which is inherited from the inherited class of base class???

DaWei 1Aug2007 22:55

Re: a small doubt.please clarify.
 
Refer to your documentation.
Quote:

Originally Posted by C++ Language Reference
The protected keyword specifies access to class members in the member-list up to the next access specifier (public or private) or the end of the class definition. Class members declared as protected can be used only by the following:

Member functions of the class that originally declared these members.

Friends of the class that originally declared these members.

Classes derived with public or protected access from the class that originally declared these members.

Direct privately derived classes that also have private access to protected members.

When preceding the name of a base class, the protected keyword specifies that the public and protected members of the base class are protected members of its derived classes.

Protected members are not as private as private members, which are accessible only to members of the class in which they are declared, but they are not as public as public members, which are accessible in any function.

Protected members that are also declared as static are accessible to any friend or member function of a derived class. Protected members that are not declared as static are accessible to friends and member functions in a derived class only through a pointer to, reference to, or object of the derived class.



All times are GMT +5.5. The time now is 07:59.