|
282 | 282 | #include <string>
|
283 | 283 |
|
284 | 284 | struct C {
|
285 |
| - std::string s; // \tcode{std::string} is the standard library class\iref{string.classes} |
| 285 | + std::string s; // \tcode{std::string} is the standard library class\iref{string.classes} |
286 | 286 | };
|
287 | 287 |
|
288 | 288 | int main() {
|
|
2458 | 2458 |
|
2459 | 2459 | void h()
|
2460 | 2460 | {
|
2461 |
| - AB::g(); // \tcode{g} is declared directly in \tcode{AB}, therefore \tcode{S} is $\{ \tcode{AB::g()} \}$ and \tcode{AB::g()} is chosen |
| 2461 | + AB::g(); // \tcode{g} is declared directly in \tcode{AB}, therefore \tcode{S} is $\{ \tcode{AB::g()} \}$ and \tcode{AB::g()} is chosen |
2462 | 2462 |
|
2463 |
| - AB::f(1); // \tcode{f} is not declared directly in \tcode{AB} so the rules are applied recursively to \tcode{A} and \tcode{B}; |
2464 |
| - // namespace \tcode{Y} is not searched and \tcode{Y::f(float)} is not considered; |
2465 |
| - // \tcode{S} is $\{ \tcode{A::f(int)}, \tcode{B::f(char)} \}$ and overload resolution chooses \tcode{A::f(int)} |
| 2463 | + AB::f(1); // \tcode{f} is not declared directly in \tcode{AB} so the rules are applied recursively to \tcode{A} and \tcode{B}; |
| 2464 | + // namespace \tcode{Y} is not searched and \tcode{Y::f(float)} is not considered; |
| 2465 | + // \tcode{S} is $\{ \tcode{A::f(int)}, \tcode{B::f(char)} \}$ and overload resolution chooses \tcode{A::f(int)} |
2466 | 2466 |
|
2467 |
| - AB::f('c'); // as above but resolution chooses \tcode{B::f(char)} |
| 2467 | + AB::f('c'); // as above but resolution chooses \tcode{B::f(char)} |
2468 | 2468 |
|
2469 |
| - AB::x++; // \tcode{x} is not declared directly in \tcode{AB}, and is not declared in \tcode{A} or \tcode{B}, so the rules |
2470 |
| - // are applied recursively to \tcode{Y} and \tcode{Z}, \tcode{S} is $\{ \}$ so the program is ill-formed |
| 2469 | + AB::x++; // \tcode{x} is not declared directly in \tcode{AB}, and is not declared in \tcode{A} or \tcode{B}, so the rules |
| 2470 | + // are applied recursively to \tcode{Y} and \tcode{Z}, \tcode{S} is $\{ \}$ so the program is ill-formed |
2471 | 2471 |
|
2472 |
| - AB::i++; // \tcode{i} is not declared directly in \tcode{AB} so the rules are applied recursively to \tcode{A} and \tcode{B}, |
2473 |
| - // \tcode{S} is $\{ \tcode{A::i}, \tcode{B::i} \}$ so the use is ambiguous and the program is ill-formed |
| 2472 | + AB::i++; // \tcode{i} is not declared directly in \tcode{AB} so the rules are applied recursively to \tcode{A} and \tcode{B}, |
| 2473 | + // \tcode{S} is $\{ \tcode{A::i}, \tcode{B::i} \}$ so the use is ambiguous and the program is ill-formed |
2474 | 2474 |
|
2475 |
| - 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 |
2476 |
| - // are applied recursively to \tcode{Y} and \tcode{Z}, \tcode{S} is $\{ \tcode{Y::h(int)}, \tcode{Z::h(double)} \}$ and |
2477 |
| - // overload resolution chooses \tcode{Z::h(double)} |
| 2475 | + 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 |
| 2476 | + // are applied recursively to \tcode{Y} and \tcode{Z}, \tcode{S} is $\{ \tcode{Y::h(int)}, \tcode{Z::h(double)} \}$ and |
| 2477 | + // overload resolution chooses \tcode{Z::h(double)} |
2478 | 2478 | }
|
2479 | 2479 | \end{codeblock}
|
2480 | 2480 | \end{example}
|
|
0 commit comments