+ 1

But really, what is the main difference between "Private" member and a "Protected" member

1st Jul 2018, 2:55 PM
StEvEn
StEvEn - avatar
5 Answers
+ 2
You cant inherite private member. Pls specify what do you mean by call private from base class.
1st Jul 2018, 3:12 PM
B K
+ 2
no you can't access them directly, as you can access public and protected member via a child class object. Private members are only accessible by the members of same class. if you try to access them outside the class directly , compiler will through you an error. ( unless you are using a friend class or friend function). but yes you can access them indirectly by accessing base class's public or protected member inside another class.
1st Jul 2018, 3:13 PM
Nikhil Dhama
Nikhil Dhama - avatar
+ 1
Main difference between them is, protected can be inherit , while private can't.
1st Jul 2018, 3:04 PM
Nikhil Dhama
Nikhil Dhama - avatar
0
Private member can be use only inside the class and cant be inherite. The protected member can be use only inside class but can be inherite.
1st Jul 2018, 3:02 PM
B K
0
but we can still call the variable (or const) that is in the private of the base class.. to the "daughter" class. is that not similar to inheritance?
1st Jul 2018, 3:07 PM
StEvEn
StEvEn - avatar