yash
Answered On : Jul 28th, 2006
we cannot inherit private members of a class

1 User has rated as useful.
Login to rate this answer.
Hi ,
There is only one case in which u can inherit a member into derived class by using PROTECTED Access specifire for that member . a member with protected specifire remain private for same class but it is possible to inherit this member into derived classes so this is the only way for this problem.
Regards,
Avinash Chaturvedi ( Avi )
Login to rate this answer.
RAJEEV CHOPRA
Answered On : Sep 8th, 2006
If we specify access specifier private to member of any class means it is private for that class.
Means child can inherit when parent will permit.
So if it is private it cannot be inherited.
Login to rate this answer.
dhivya
Answered On : Oct 27th, 2006
Private members cannot be inherited,
only public and protected members can be inherited.
private members can be accessed with the help of FRIEND function.
protected members can inherit as protected,public members can be inherited as public, but private cannot be inherited.

2 Users have rated as useful.
Login to rate this answer.
ye, make the derived class a friend class of the base class
Login to rate this answer.
We cannot even we use protected inheritance
Look:
class Dericed: protected Base
{
}
Protected inheritance
It is almost never used, except in very particular cases. With protected inheritance, the public and protected members become protected, and private members stay private.
To summarize in table form:
| Protected inheritance |
| Base access specifier | Derived access specifier | Derived class access? | Outside access?(Other calsses)
|
| Public | Protected | Yes | No |
| Private | Private | No | No |
| Protected | Protected | Yes | No |
Protected inheritance is similar to private inheritance. However, classes derived from the derived class still have access to the public and protected members directly. The public (stuff outside the class) does not.
Login to rate this answer.
For more explanation, you can see in my previous answer that we can inherit, but we can not access it from the derived class.
Login to rate this answer.
No we cannot inherit the private member of a superclass.
Login to rate this answer.
sandeep
Answered On : Jul 18th, 2011
we can inherit with get set properties.
Login to rate this answer.
sundar
Answered On : Jul 22nd, 2011
we can inherit in the private mode of visibility.
Login to rate this answer.
vikas
Answered On : Jul 26th, 2011
yes by making it friend class
Login to rate this answer.
sean
Answered On : Oct 10th, 2011
if you can declare the sub class in the base class (i.e if you make sub class as inner class in base class), you will be able to access the private members of the base class.
Login to rate this answer.
we cannot inherit private members of a class,but you can use friend functions to access private data
Login to rate this answer.