So, the simplest case:
class Parent
{
protected:
int p;
};
class Child : public Parent
{
public:
int getP() const {
return p;
}
};
Why are we using public
here? I've seen it many times, but still don't understand what it does. It seems to me that Child
can get access to protected attributes of Parent
in any case.