Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Sections 3.5.2 and 3.5.3 of the language specification spell this out, I'll post 3.5.2 for convenience (it's shorter!) and let you find 3.5.3 on your own. </p> <blockquote> <p>In intuitive terms, when a type or member M is accessed, the following steps are evaluated to ensure that the access is permitted:</p> <ul> <li>First, if M is declared within a type (as opposed to a compilation unit or a namespace), a compile-time error occurs if that type is not accessible.</li> <li>Then, if M is public, the access is permitted.</li> <li>Otherwise, if M is protected internal, the access is permitted if it occurs within the program in which M is declared, or if it occurs within a class derived from the class in which M is declared and takes place through the derived class type (§3.5.3).</li> <li><strong>Otherwise, if M is protected, the access is permitted if it occurs within the class in which M is declared, or if it occurs within a class derived from the class in which M is declared and takes place through the derived class type (§3.5.3).</strong></li> <li>Otherwise, if M is internal, the access is permitted if it occurs within the program in which M is declared.</li> <li>Otherwise, if M is private, the access is permitted if it occurs within the type in which M is declared.</li> <li>Otherwise, the type or member is inaccessible, and a compile-time error occurs.</li> </ul> </blockquote> <p>Basically, access to protected members of the base have to be through instances of the derived. As you said, siblings cannot access each others' protected members, but the language specification also prohibits children from accessing protected members of the base unless the reference is through the child. </p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload