|
314 | 314 | #include <string> |
315 | 315 |
|
316 | 316 | struct C { |
317 | | - std::string s; // \tcode{std::string} is the standard library class\iref{string.classes} |
| 317 | + std::string s; // \tcode{std::string} is the standard library class\iref{string.classes} |
318 | 318 | }; |
319 | 319 |
|
320 | 320 | int main() { |
|
2616 | 2616 |
|
2617 | 2617 | void h() |
2618 | 2618 | { |
2619 | | - AB::g(); // \tcode{g} is declared directly in \tcode{AB}, therefore \tcode{S} is $\{ \tcode{AB::g()} \}$ and \tcode{AB::g()} is chosen |
| 2619 | + AB::g(); // \tcode{g} is declared directly in \tcode{AB}, therefore \tcode{S} is $\{ \tcode{AB::g()} \}$ and \tcode{AB::g()} is chosen |
2620 | 2620 |
|
2621 | | - AB::f(1); // \tcode{f} is not declared directly in \tcode{AB} so the rules are applied recursively to \tcode{A} and \tcode{B}; |
2622 | | - // namespace \tcode{Y} is not searched and \tcode{Y::f(float)} is not considered; |
2623 | | - // \tcode{S} is $\{ \tcode{A::f(int)}, \tcode{B::f(char)} \}$ and overload resolution chooses \tcode{A::f(int)} |
| 2621 | + AB::f(1); // \tcode{f} is not declared directly in \tcode{AB} so the rules are applied recursively to \tcode{A} and \tcode{B}; |
| 2622 | + // namespace \tcode{Y} is not searched and \tcode{Y::f(float)} is not considered; |
| 2623 | + // \tcode{S} is $\{ \tcode{A::f(int)}, \tcode{B::f(char)} \}$ and overload resolution chooses \tcode{A::f(int)} |
2624 | 2624 |
|
2625 | | - AB::f('c'); // as above but resolution chooses \tcode{B::f(char)} |
| 2625 | + AB::f('c'); // as above but resolution chooses \tcode{B::f(char)} |
2626 | 2626 |
|
2627 | | - AB::x++; // \tcode{x} is not declared directly in \tcode{AB}, and is not declared in \tcode{A} or \tcode{B}, so the rules |
2628 | | - // are applied recursively to \tcode{Y} and \tcode{Z}, \tcode{S} is $\{ \}$ so the program is ill-formed |
| 2627 | + AB::x++; // \tcode{x} is not declared directly in \tcode{AB}, and is not declared in \tcode{A} or \tcode{B}, so the rules |
| 2628 | + // are applied recursively to \tcode{Y} and \tcode{Z}, \tcode{S} is $\{ \}$ so the program is ill-formed |
2629 | 2629 |
|
2630 | | - AB::i++; // \tcode{i} is not declared directly in \tcode{AB} so the rules are applied recursively to \tcode{A} and \tcode{B}, |
2631 | | - // \tcode{S} is $\{ \tcode{A::i}, \tcode{B::i} \}$ so the use is ambiguous and the program is ill-formed |
| 2630 | + AB::i++; // \tcode{i} is not declared directly in \tcode{AB} so the rules are applied recursively to \tcode{A} and \tcode{B}, |
| 2631 | + // \tcode{S} is $\{ \tcode{A::i}, \tcode{B::i} \}$ so the use is ambiguous and the program is ill-formed |
2632 | 2632 |
|
2633 | | - 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 |
2634 | | - // are applied recursively to \tcode{Y} and \tcode{Z}, \tcode{S} is $\{ \tcode{Y::h(int)}, \tcode{Z::h(double)} \}$ and |
2635 | | - // overload resolution chooses \tcode{Z::h(double)} |
| 2633 | + 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 |
| 2634 | + // are applied recursively to \tcode{Y} and \tcode{Z}, \tcode{S} is $\{ \tcode{Y::h(int)}, \tcode{Z::h(double)} \}$ and |
| 2635 | + // overload resolution chooses \tcode{Z::h(double)} |
2636 | 2636 | } |
2637 | 2637 | \end{codeblock} |
2638 | 2638 | \end{example} |
|
0 commit comments