Java和C ++中默认是私有类还是公共类? [英] Is a class private or public by default in Java and C++?
本文介绍了Java和C ++中默认是私有类还是公共类?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
默认情况下,Java和C ++中的类是私有还是公共?
Are classes private or public by default in Java and C++?
推荐答案
-
Java :
默认情况下,类可见性是包私有的,即仅对同一包中的类可见。
By default, the classes visibility is package private, i.e. only visible for classes in the same package.
C ++ :
该类没有像Java那样定义的可见性。如果将它们包含在编译单元中,它们是可见的。
The class has no visibility defined like in Java. They are visible if you included them to the compilation unit.
这篇关于Java和C ++中默认是私有类还是公共类?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文