Is a class private or public by default in Java and C++?
问题 Are classes private or public by default in Java and C++? 回答1: Java : By default, the classes visibility is package private, i.e. only visible for classes in the same package. C++ : The class has no visibility defined like in Java. They are visible if you included them to the compilation unit. 回答2: In Java, a top-level class is either public or non-public. There is no "private". You can only use the public keyword or leave it off. If you leave it off it is non-public, i.e., visible only to