The Google C++ style guide states in the section about inheritance that:
Limit the use of protected to those member functions that might need to be accessed from subclasses. Note that data members should be private.
Consider now the following case:
class A {
private:
double m;
// ...
}
class B : public A {
// ...
}
I guess the correct approach is that class A implements getter/setter functions for m such that class B can access it?
I don't really get why this rule has been chosen instead of using protected
for data members as well. Could someone explain?