tmp/tmp6q05vdb8/{from.md → to.md}
RENAMED
|
@@ -24,53 +24,49 @@ are type mismatches, and that
|
|
| 24 |
``` cpp
|
| 25 |
int f(X);
|
| 26 |
int f(Y);
|
| 27 |
```
|
| 28 |
|
| 29 |
-
declare
|
| 30 |
-
|
| 31 |
|
| 32 |
``` cpp
|
| 33 |
struct S { int a; };
|
| 34 |
struct S { int a; }; // error: double definition
|
| 35 |
```
|
| 36 |
|
| 37 |
is ill-formed because it defines `S` twice.
|
| 38 |
|
| 39 |
— *end example*]
|
| 40 |
|
| 41 |
-
|
| 42 |
-
|
| 43 |
-
|
| 44 |
-
|
| 45 |
-
|
| 46 |
-
the class can be referred to only using an *elaborated-type-specifier*
|
| 47 |
-
[[basic.lookup.elab]].
|
| 48 |
|
| 49 |
[*Example 2*:
|
| 50 |
|
| 51 |
``` cpp
|
| 52 |
struct stat {
|
| 53 |
// ...
|
| 54 |
};
|
| 55 |
|
| 56 |
stat gstat; // use plain stat to define variable
|
| 57 |
|
| 58 |
-
int stat(struct stat*); //
|
| 59 |
|
| 60 |
void f() {
|
| 61 |
struct stat* ps; // struct prefix needed to name struct stat
|
| 62 |
-
stat(ps); // call stat
|
| 63 |
}
|
| 64 |
```
|
| 65 |
|
| 66 |
— *end example*]
|
| 67 |
|
| 68 |
-
|
| 69 |
-
|
| 70 |
-
declaration of the identifier as a class name. It introduces the class
|
| 71 |
-
name into the current scope.
|
| 72 |
|
| 73 |
[*Example 3*:
|
| 74 |
|
| 75 |
``` cpp
|
| 76 |
struct s { int a; };
|
|
@@ -83,12 +79,10 @@ void g() {
|
|
| 83 |
}
|
| 84 |
```
|
| 85 |
|
| 86 |
— *end example*]
|
| 87 |
|
| 88 |
-
[*Note 1*:
|
| 89 |
-
|
| 90 |
Such declarations allow definition of classes that refer to each other.
|
| 91 |
|
| 92 |
[*Example 4*:
|
| 93 |
|
| 94 |
``` cpp
|
|
@@ -112,12 +106,12 @@ functions in [[over.oper]].
|
|
| 112 |
|
| 113 |
— *end note*]
|
| 114 |
|
| 115 |
[*Note 2*: An *elaborated-type-specifier* [[dcl.type.elab]] can also be
|
| 116 |
used as a *type-specifier* as part of a declaration. It differs from a
|
| 117 |
-
class declaration in that
|
| 118 |
-
|
| 119 |
|
| 120 |
[*Example 5*:
|
| 121 |
|
| 122 |
``` cpp
|
| 123 |
struct s { int a; };
|
|
|
|
| 24 |
``` cpp
|
| 25 |
int f(X);
|
| 26 |
int f(Y);
|
| 27 |
```
|
| 28 |
|
| 29 |
+
declare overloads [[over]] named `f` and not simply a single function
|
| 30 |
+
`f` twice. For the same reason,
|
| 31 |
|
| 32 |
``` cpp
|
| 33 |
struct S { int a; };
|
| 34 |
struct S { int a; }; // error: double definition
|
| 35 |
```
|
| 36 |
|
| 37 |
is ill-formed because it defines `S` twice.
|
| 38 |
|
| 39 |
— *end example*]
|
| 40 |
|
| 41 |
+
[*Note 1*:
|
| 42 |
+
|
| 43 |
+
It can be necessary to use an *elaborated-type-specifier* to refer to a
|
| 44 |
+
class that belongs to a scope in which its name is also bound to a
|
| 45 |
+
variable, function, or enumerator [[basic.lookup.elab]].
|
|
|
|
|
|
|
| 46 |
|
| 47 |
[*Example 2*:
|
| 48 |
|
| 49 |
``` cpp
|
| 50 |
struct stat {
|
| 51 |
// ...
|
| 52 |
};
|
| 53 |
|
| 54 |
stat gstat; // use plain stat to define variable
|
| 55 |
|
| 56 |
+
int stat(struct stat*); // stat now also names a function
|
| 57 |
|
| 58 |
void f() {
|
| 59 |
struct stat* ps; // struct prefix needed to name struct stat
|
| 60 |
+
stat(ps); // call stat function
|
| 61 |
}
|
| 62 |
```
|
| 63 |
|
| 64 |
— *end example*]
|
| 65 |
|
| 66 |
+
An *elaborated-type-specifier* can also be used to declare an
|
| 67 |
+
*identifier* as a *class-name*.
|
|
|
|
|
|
|
| 68 |
|
| 69 |
[*Example 3*:
|
| 70 |
|
| 71 |
``` cpp
|
| 72 |
struct s { int a; };
|
|
|
|
| 79 |
}
|
| 80 |
```
|
| 81 |
|
| 82 |
— *end example*]
|
| 83 |
|
|
|
|
|
|
|
| 84 |
Such declarations allow definition of classes that refer to each other.
|
| 85 |
|
| 86 |
[*Example 4*:
|
| 87 |
|
| 88 |
``` cpp
|
|
|
|
| 106 |
|
| 107 |
— *end note*]
|
| 108 |
|
| 109 |
[*Note 2*: An *elaborated-type-specifier* [[dcl.type.elab]] can also be
|
| 110 |
used as a *type-specifier* as part of a declaration. It differs from a
|
| 111 |
+
class declaration in that it can refer to an existing class of the given
|
| 112 |
+
name. — *end note*]
|
| 113 |
|
| 114 |
[*Example 5*:
|
| 115 |
|
| 116 |
``` cpp
|
| 117 |
struct s { int a; };
|