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