+ 2

C++ - Inheritance and access specifiers

What are access specifiers in derived classes of protected and public members of a base class? Are rules equal in other OO languages (Java, C# and so on)?

20th Sep 2019, 3:35 PM
Paolo De Nictolis
Paolo De Nictolis - avatar
4 Respostas
+ 5
✓Private inheritance: Public and protected members of base class become private of the derived. ✓Protected inheritance: Public and protected members of base become protected members of derived. ✓Public inheritance: Protected members are made protected and public members are made public. NOTE : in any kind of inheritance the security level of datatypes does not decrease. And private members are never derivable.
20th Sep 2019, 5:01 PM
Manoj
Manoj - avatar
+ 4
Sorry, probably I wasn't clear. Protected attributes of base class, in derived classes do they become private, protected or public? And public attributes of base class?
20th Sep 2019, 4:08 PM
Paolo De Nictolis
Paolo De Nictolis - avatar
+ 2
The access specifiers of classes are : - private - protected - public I believe they serve the same purpose in many, possibly all programming languages. http://www.trytoprogram.com/cplusplus-programming/access-specifiers/
20th Sep 2019, 4:03 PM
Manual
Manual - avatar