I’m new to C++, and I’m familiar with Java. The first thing I was wondering about when I started looking at C++ code is that classes themselves (not the members) don’t have access specifiers such private, protected and public. Exemples here and here.
public class A { // This line.
private class B { } // Not this line.
}
Why is that so?
There’s no access modifier at the level of classes, since the language has no concept of package. But there is at the level of data members, member functions and inheritence:
The closest you can get is declaring nested classes inside a class: