problem in inheritance?
My question is that if I inherit a base class as protected in derived class,than am I allowed to use both getter and setter functions using protected members of base class in derived class?Or I can just set the value in derived class but can not return it in the scope of derived class.
If the base class provides getter or setter functions, the derived class can call them - as long as those setters and getters are not private to the base class.
Any member function of the derived class can also access (retrieve or modify the values) data members of the base class - again, as long as those data members are not private.
Protected inheritence does not change that, except that functions which use the derived class cannot access the base class or any of its data or member functions (unless that function is a friend or member of the derived class).
I've never heard of an actual use case for protected inheritance. It's in the language for the sake of consistency with member access control, but I really don't think anyone uses it in production.
Basically, protected inheritance turns all public members of the base class into protected members in the derived class. Protected and private members aren't touched.
I take it that it's a good thing if you want to inherit from a base class which is set up for further derivation and make your your derived class also can be derived properly from.
thanx Elysia its clear now...cheers