From Jason Turner

[class.nest]

Diff to HTML by rtfpessoa

Files changed (1) hide show
  1. tmp/tmpkoiri2a7/{from.md → to.md} +18 -4
tmp/tmpkoiri2a7/{from.md → to.md} RENAMED
@@ -1,12 +1,16 @@
1
- ## Nested class declarations <a id="class.nest">[[class.nest]]</a>
2
 
3
  A class can be declared within another class. A class declared within
4
  another is called a *nested* class. The name of a nested class is local
5
  to its enclosing class. The nested class is in the scope of its
6
- enclosing class. See  [[expr.prim]] for restrictions on the use of
7
- non-static data members and non-static member functions.
 
 
 
 
8
 
9
  ``` cpp
10
  int x;
11
  int y;
12
 
@@ -29,40 +33,50 @@ struct enclose {
29
  };
30
 
31
  inner* p = 0; // error: inner not in scope
32
  ```
33
 
 
 
34
  Member functions and static data members of a nested class can be
35
  defined in a namespace scope enclosing the definition of their class.
36
 
 
 
37
  ``` cpp
38
  struct enclose {
39
  struct inner {
40
  static int x;
41
  void f(int i);
42
  };
43
  };
44
 
45
  int enclose::inner::x = 1;
46
 
47
- void enclose::inner::f(int i) { /* ... */ }
48
  ```
49
 
 
 
50
  If class `X` is defined in a namespace scope, a nested class `Y` may be
51
  declared in class `X` and later defined in the definition of class `X`
52
  or be later defined in a namespace scope enclosing the definition of
53
  class `X`.
54
 
 
 
55
  ``` cpp
56
  class E {
57
  class I1; // forward declaration of nested class
58
  class I2;
59
  class I1 { }; // definition of nested class
60
  };
61
  class E::I2 { }; // definition of nested class
62
  ```
63
 
 
 
64
  Like a member function, a friend function ([[class.friend]]) defined
65
  within a nested class is in the lexical scope of that class; it obeys
66
  the same rules for name binding as a static member function of that
67
  class ([[class.static]]), but it has no special access rights to
68
  members of an enclosing class.
 
1
+ ### Nested class declarations <a id="class.nest">[[class.nest]]</a>
2
 
3
  A class can be declared within another class. A class declared within
4
  another is called a *nested* class. The name of a nested class is local
5
  to its enclosing class. The nested class is in the scope of its
6
+ enclosing class.
7
+
8
+ [*Note 1*: See  [[expr.prim]] for restrictions on the use of non-static
9
+ data members and non-static member functions. — *end note*]
10
+
11
+ [*Example 1*:
12
 
13
  ``` cpp
14
  int x;
15
  int y;
16
 
 
33
  };
34
 
35
  inner* p = 0; // error: inner not in scope
36
  ```
37
 
38
+ — *end example*]
39
+
40
  Member functions and static data members of a nested class can be
41
  defined in a namespace scope enclosing the definition of their class.
42
 
43
+ [*Example 2*:
44
+
45
  ``` cpp
46
  struct enclose {
47
  struct inner {
48
  static int x;
49
  void f(int i);
50
  };
51
  };
52
 
53
  int enclose::inner::x = 1;
54
 
55
+ void enclose::inner::f(int i) { ... }
56
  ```
57
 
58
+ — *end example*]
59
+
60
  If class `X` is defined in a namespace scope, a nested class `Y` may be
61
  declared in class `X` and later defined in the definition of class `X`
62
  or be later defined in a namespace scope enclosing the definition of
63
  class `X`.
64
 
65
+ [*Example 3*:
66
+
67
  ``` cpp
68
  class E {
69
  class I1; // forward declaration of nested class
70
  class I2;
71
  class I1 { }; // definition of nested class
72
  };
73
  class E::I2 { }; // definition of nested class
74
  ```
75
 
76
+ — *end example*]
77
+
78
  Like a member function, a friend function ([[class.friend]]) defined
79
  within a nested class is in the lexical scope of that class; it obeys
80
  the same rules for name binding as a static member function of that
81
  class ([[class.static]]), but it has no special access rights to
82
  members of an enclosing class.