disable broken tests on net_4_0
[mcs.git] / docs / ecma334 / 10.5.3.xml
blob91065dac1340a9989f37799e32c26f109dc49049
1 <?xml version="1.0"?>
2 <clause number="10.5.3" title="Protected access for instance members">
3   <paragraph>When a protected instance member is accessed outside the program text of the class in which it is declared, and when a protected internal instance member is accessed outside the program text of the program in which it is declared, the access is required to take place through an instance of the derived class type in which the access occurs. Let B be a base class that declares a protected instance member M, and let D be a class that derives from B. Within the <non_terminal where="17.1.3">class-body</non_terminal> of D, access to M can take one of the following forms: <list><list_item> An unqualified <non_terminal where="10.8">type-name</non_terminal> or <non_terminal where="14.5">primary-expression</non_terminal> of the form M. </list_item><list_item> A <non_terminal where="14.5">primary-expression</non_terminal> of the form E.M, provided the type of E is D or a class derived from D. </list_item><list_item> A <non_terminal where="14.5">primary-expression</non_terminal> of the form base.M. </list_item></list></paragraph>
4   <paragraph>In addition to these forms of access, a derived class can access a protected instance constructor of a base class in a <non_terminal where="17.10">constructor-initializer</non_terminal> (<hyperlink>17.10.1</hyperlink>). </paragraph>
5   <paragraph>
6     <example>[Example: In the example <code_example><![CDATA[
7 public class A  
8 {  
9    protected int x;  
10    static void F(A a, B b) {  
11       a.x = 1;   // Ok  
12       b.x = 1;   // Ok  
13    }  
14 }  
15 public class B: A  
16 {  
17    static void F(A a, B b) {  
18       a.x = 1;   // Error, must access through instance of B  
19       b.x = 1;   // Ok  
20    }  
21 }  
22 ]]></code_example>within A, it is possible to access x through instances of both A and B, since in either case the access takes place through an instance of A or a class derived from A. However, within B, it is not possible to access x through an instance of A, since A does not derive from B. end example]</example>
23   </paragraph>
24 </clause>