In C++, a class/struct/Union has three access specifiers.
These access specifiers describe how class members can be accessed.
Of course, any class member is available within that class (Inside any member function of that same class).
Moving on to access specifiers, they are as follows:
Public - Members designated as Public are available from outside the Class via a class object.
Protected - Protected members are available from outside the class, but only in a class derived from it.
Private members can only be accessed from within the class.
Outside access is not permitted.
An Example of Source Code:
class MyClass
{
public:
int a;
protected:
int b;
private:
int c;
};
int main()
{
MyClass obj;
obj.a = 10; //Allowed
obj.b = 20; //Not Allowed, gives compiler error
obj.c = 30; //Not Allowed, gives compiler error
}