i am still a little confused with scoping methods of a base class for a derived class.
1 2 3 4 5 6 7 8 9 10 11 12
class A
{
private:
int a;
public :
void doSmthing(void);
};
class B : (private/public/protected) A
{
...
}
Could someone kindly, and if possible, with details, explain how are three calls different. Because I know B can never access A's private variables !! So what is that private A call doing ?
And where are these three used ? which scenarios etc .
Let's just put it simple: public inheritence is basically inheritance. Private inheritance is just that, inheritance but it's sort of "invisible" to the outside, protected the same way, with the difference of it being visible to derived classes. You can think of private inheritance as a composition of some sorts... in general you can say you don't really need (nor want) it, though in some rare cases it can come in handy.