It’s kind of hard to understand at this stage but It’s an accessor level.
You have public
, protected
, and private
.
public
- can be accessed anywhere
protected
- can only be accessed by the class itself and derived classes
private
can only be accessed by the class itself.
Here’s a code example
class A
{
public:
void Public();
protected:
void Protected();
private:
void Private();
}
class B : public A
{
void Foo()
{
Public(); //okay inherited from A and accessible
Protected(); //okay inherited from A and accessible
Private();//error inherited from A and inaccessible
}
};
int main()
{
A a;
a.Public(); //ok
a.Protected(); //error inaccessible
a.Private(); //error inaccessible
}