C++ classes (public, private, and protected)

In C++ there is no notion of an entire class having an access specifier the way that there is in Java or C#. If a piece of code has visibility of a class, it can reference the name of that class and manipulate it. That said, there are a few restrictions on this. Just because you can reference a class doesn’t mean you can instantiate it, for example, since the constructor might be marked private. Similarly, if the class is a nested class declared in another class’s private or protected section, then the class won’t be accessible outside from that class and its friends.

Leave a Comment