Below is a subtle example of accessing an instance\'s protected field x. B is a subclass of A so any variable of type B is also of type A. Why can B::foo() access b\'s x fie
Class B is not identical to class A. That's why members of class B cannot access non-public members of class A.
B
A
On the other hand, class B derives publicly from class A, so class B now has a (protected) member x which any member of class B can access.
x