Because the Package concept does not exist, the protected of C ++ is different from that of protected in Java. protected in Java is not only accessible to sub-objects, but also to other parts of the package, it can also be displayed through sub-object calls, such
Package pack1
Public Class {
Protected int;
}
Package pack1
Public Class B {
Public static void main (string [] ARGs ){
System. Out. println ();
}
}
The above code is correct, but if B and A are not in the same package, they cannot be accessed. Therefore, in Java, the visibility of protected is similar to that of packaged, but in inheritance, it does not define packets, the packaged permission does not allow the sub-object to access the attributes of the package access permission of the parent object in other packages.
In C ++, the protected attribute is strictly defined, that is, it only has the vertical access permission, and can only be accessed by itself and its descendants. Only the protected attribute of a class is limited, only internal and sub-objects can be accessed, but they are invisible in other places. The following table lists the access to attributes inherited by C ++ (narrow access ):
Public attribute protected attribute private attribute
Public inherits from public protected and is invisible.
Protected inherits protected which is invisible
Private inherits Private invisible
Http://www.cnblogs.com/cucmehp/archive/2008/10/28/1321106.html ()