Do inherited classes also inherit the private members (methods, variables, etc...)? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 2

Do inherited classes also inherit the private members (methods, variables, etc...)?

9th Jan 2017, 3:03 PM
Enrique de la Cal
Enrique de la Cal - avatar
3 Answers
+ 5
Yes, they do. But you can not access them from derived class. So if your base class have a public or protected function, that works with private members, it still work in derived class.
9th Jan 2017, 3:08 PM
WittyBit
WittyBit - avatar
+ 2
ok thanks :)
9th Jan 2017, 3:15 PM
Enrique de la Cal
Enrique de la Cal - avatar
+ 1
private members of class won't inherit.
19th Feb 2017, 11:09 AM
syed Afzal Ahamad