Scope of base class

Hi All

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 .
That's not a function call - that shows how B will inherit A (either private, or protected or public).

Start here (about halfway down - you will see Inheritance between classes)
http://www.cplusplus.com/doc/tutorial/inheritance/

or on any other thousands of pages listed in this google search here:
http://www.google.co.uk/search?hl=&q=c%2B%2B+inheritance&sourceid=navclient-ff&rlz=1B3GGLL_en-GB___GB395&ie=UTF-8&aq=0&oq=C%2B%2B+inheritance
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.
Topic archived. No new replies allowed.