I have a class A, which have a field val declared as private. I want to declare a class B, that inherit from A and have an access to val. Is there a way to do it on C++?
You need to define it as protected. Protected members are inherited to child classes but are not accessible from the outside world.
protected