|
284 | 284 | #include <string>
|
285 | 285 |
|
286 | 286 | struct C {
|
287 |
| - std::string s; // \tcode{std::string} is the standard library class\iref{string.classes} |
| 287 | + std::string s; // \tcode{std::string} is the standard library class\iref{string.classes} |
288 | 288 | };
|
289 | 289 |
|
290 | 290 | int main() {
|
|
2496 | 2496 |
|
2497 | 2497 | void h()
|
2498 | 2498 | {
|
2499 |
| - AB::g(); // \tcode{g} is declared directly in \tcode{AB}, therefore \tcode{S} is $\{ \tcode{AB::g()} \}$ and \tcode{AB::g()} is chosen |
| 2499 | + AB::g(); // \tcode{g} is declared directly in \tcode{AB}, therefore \tcode{S} is $\{ \tcode{AB::g()} \}$ and \tcode{AB::g()} is chosen |
2500 | 2500 |
|
2501 |
| - AB::f(1); // \tcode{f} is not declared directly in \tcode{AB} so the rules are applied recursively to \tcode{A} and \tcode{B}; |
2502 |
| - // namespace \tcode{Y} is not searched and \tcode{Y::f(float)} is not considered; |
2503 |
| - // \tcode{S} is $\{ \tcode{A::f(int)}, \tcode{B::f(char)} \}$ and overload resolution chooses \tcode{A::f(int)} |
| 2501 | + AB::f(1); // \tcode{f} is not declared directly in \tcode{AB} so the rules are applied recursively to \tcode{A} and \tcode{B}; |
| 2502 | + // namespace \tcode{Y} is not searched and \tcode{Y::f(float)} is not considered; |
| 2503 | + // \tcode{S} is $\{ \tcode{A::f(int)}, \tcode{B::f(char)} \}$ and overload resolution chooses \tcode{A::f(int)} |
2504 | 2504 |
|
2505 |
| - AB::f('c'); // as above but resolution chooses \tcode{B::f(char)} |
| 2505 | + AB::f('c'); // as above but resolution chooses \tcode{B::f(char)} |
2506 | 2506 |
|
2507 |
| - AB::x++; // \tcode{x} is not declared directly in \tcode{AB}, and is not declared in \tcode{A} or \tcode{B}, so the rules |
2508 |
| - // are applied recursively to \tcode{Y} and \tcode{Z}, \tcode{S} is $\{ \}$ so the program is ill-formed |
| 2507 | + AB::x++; // \tcode{x} is not declared directly in \tcode{AB}, and is not declared in \tcode{A} or \tcode{B}, so the rules |
| 2508 | + // are applied recursively to \tcode{Y} and \tcode{Z}, \tcode{S} is $\{ \}$ so the program is ill-formed |
2509 | 2509 |
|
2510 |
| - AB::i++; // \tcode{i} is not declared directly in \tcode{AB} so the rules are applied recursively to \tcode{A} and \tcode{B}, |
2511 |
| - // \tcode{S} is $\{ \tcode{A::i}, \tcode{B::i} \}$ so the use is ambiguous and the program is ill-formed |
| 2510 | + AB::i++; // \tcode{i} is not declared directly in \tcode{AB} so the rules are applied recursively to \tcode{A} and \tcode{B}, |
| 2511 | + // \tcode{S} is $\{ \tcode{A::i}, \tcode{B::i} \}$ so the use is ambiguous and the program is ill-formed |
2512 | 2512 |
|
2513 |
| - AB::h(16.8); // \tcode{h} is not declared directly in \tcode{AB} and not declared directly in \tcode{A} or \tcode{B} so the rules |
2514 |
| - // are applied recursively to \tcode{Y} and \tcode{Z}, \tcode{S} is $\{ \tcode{Y::h(int)}, \tcode{Z::h(double)} \}$ and |
2515 |
| - // overload resolution chooses \tcode{Z::h(double)} |
| 2513 | + AB::h(16.8); // \tcode{h} is not declared directly in \tcode{AB} and not declared directly in \tcode{A} or \tcode{B} so the rules |
| 2514 | + // are applied recursively to \tcode{Y} and \tcode{Z}, \tcode{S} is $\{ \tcode{Y::h(int)}, \tcode{Z::h(double)} \}$ and |
| 2515 | + // overload resolution chooses \tcode{Z::h(double)} |
2516 | 2516 | }
|
2517 | 2517 | \end{codeblock}
|
2518 | 2518 | \end{example}
|
|
0 commit comments