class Base{
public:
void setX(int a) {x=a;}
private:
int x;
};
class D1: protected Base{};?
class D2: public D1{};
what is the access level for the member function setX() in the class D2 ?
is it protected ? of private?
Can any kind people explain this, I mean how to judge access level regarding inherence ….something like this. thank you!
Edited: Add on more question
but WHy I cannot call : d2.setX() ? d2 is a instance of D2. It turns out compiler error – user658213 0 secs ago edit
SetX is protected and x is inaccessible from D2. You can only restrict access, you cannot broaden it.