0

I have a class A with a private variable a. Class B is a subclass of A. In class B_Test, I would like to wrtite something like "B b; b.a;", I put friend class C in both Class A and Class B but it still no works.

Any idea? Thank you.

(Sorry I make a mistake in my code when I post this question. It is solved now). Rod_Algonquin is right. Thank you.)

xieziban
  • 77
  • 1
  • 5

1 Answers1

3

Private members do not get inherited. If you want to access that member in the inherited class, you need to use protected modifier.

Andro
  • 2,232
  • 1
  • 27
  • 40