If I have two classes A and B, such that B inehrits A. In other words, A is the base class, and B is the derived class.
Now, suppose that class A has private members. Since class B inherited class A, the private data members became part of class B.
As we know, private members are said not to be accessed even by derived classes, but, they are now in the derived class. What is the value of privacy in this case?
Thanks.
They aren’t usable in any way by member functions of
B, but they will be useful to member functions ofA, whichBin turn will rely on. It’s simply another level of encapsulation (Bshouldn’t care how the functionality ofAis implemented).