Private vs protected.

1
2
3
4
5
6
7
8
9
10
11
12
class AA
{
private:
int qq;
string bb;

protected:
double pp;
}

public:
// blah blah 


what is the different in using Private and Protected inheritance?
private=only use class AA and object of class AA
protected= you will go to http://msdn.microsoft.com/en-us/library/e761de5s.aspx
private member can only be access in class AA through it methods but denial access from the derived class.
but protected can be access by the derived classes.


am i right?
yes sure.but this subject have some specification
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
class AA
{
private:
int qq;
string bb;
protected:
double pp;
}
public:
// blah blah


class BB : class AA
{
private:
string bb;
}


explain the access specifier, protected for pp in class AA
Topic archived. No new replies allowed.