Access control for inheritence means how much do others have access to members of the class from which a given class is inherited from.
For instance, if B is derived from A, can other classes and classes drived from B see the members of A?
Well, if B is derived from A publically, then everyone can reference the public members of A through B.
If B is derived from A protected, then only classes direived from B can see the public and protected members of A.
If B is derived from A privately, only B can see the members of A. No one else, including other classes, global functions, and classes inherited from B, can see the members of B (regardless if those members themselves are declared private, public or protected.)Describe Access control in inherited classes - C++?
Good answer!
Subscribe to:
Post Comments
(Atom)
No comments:
Post a Comment