|
324 | 324 | #include <string> |
325 | 325 |
|
326 | 326 | struct C { |
327 | | - std::string s; // \tcode{std::string} is the standard library class\iref{string.classes} |
| 327 | + std::string s; // \tcode{std::string} is the standard library class\iref{string.classes} |
328 | 328 | }; |
329 | 329 |
|
330 | 330 | int main() { |
|
2628 | 2628 |
|
2629 | 2629 | void h() |
2630 | 2630 | { |
2631 | | - AB::g(); // \tcode{g} is declared directly in \tcode{AB}, therefore \tcode{S} is $\{ \tcode{AB::g()} \}$ and \tcode{AB::g()} is chosen |
| 2631 | + AB::g(); // \tcode{g} is declared directly in \tcode{AB}, therefore \tcode{S} is $\{ \tcode{AB::g()} \}$ and \tcode{AB::g()} is chosen |
2632 | 2632 |
|
2633 | | - AB::f(1); // \tcode{f} is not declared directly in \tcode{AB} so the rules are applied recursively to \tcode{A} and \tcode{B}; |
2634 | | - // namespace \tcode{Y} is not searched and \tcode{Y::f(float)} is not considered; |
2635 | | - // \tcode{S} is $\{ \tcode{A::f(int)}, \tcode{B::f(char)} \}$ and overload resolution chooses \tcode{A::f(int)} |
| 2633 | + AB::f(1); // \tcode{f} is not declared directly in \tcode{AB} so the rules are applied recursively to \tcode{A} and \tcode{B}; |
| 2634 | + // namespace \tcode{Y} is not searched and \tcode{Y::f(float)} is not considered; |
| 2635 | + // \tcode{S} is $\{ \tcode{A::f(int)}, \tcode{B::f(char)} \}$ and overload resolution chooses \tcode{A::f(int)} |
2636 | 2636 |
|
2637 | | - AB::f('c'); // as above but resolution chooses \tcode{B::f(char)} |
| 2637 | + AB::f('c'); // as above but resolution chooses \tcode{B::f(char)} |
2638 | 2638 |
|
2639 | | - AB::x++; // \tcode{x} is not declared directly in \tcode{AB}, and is not declared in \tcode{A} or \tcode{B}, so the rules |
2640 | | - // are applied recursively to \tcode{Y} and \tcode{Z}, \tcode{S} is $\{ \}$ so the program is ill-formed |
| 2639 | + AB::x++; // \tcode{x} is not declared directly in \tcode{AB}, and is not declared in \tcode{A} or \tcode{B}, so the rules |
| 2640 | + // are applied recursively to \tcode{Y} and \tcode{Z}, \tcode{S} is $\{ \}$ so the program is ill-formed |
2641 | 2641 |
|
2642 | | - AB::i++; // \tcode{i} is not declared directly in \tcode{AB} so the rules are applied recursively to \tcode{A} and \tcode{B}, |
2643 | | - // \tcode{S} is $\{ \tcode{A::i}, \tcode{B::i} \}$ so the use is ambiguous and the program is ill-formed |
| 2642 | + AB::i++; // \tcode{i} is not declared directly in \tcode{AB} so the rules are applied recursively to \tcode{A} and \tcode{B}, |
| 2643 | + // \tcode{S} is $\{ \tcode{A::i}, \tcode{B::i} \}$ so the use is ambiguous and the program is ill-formed |
2644 | 2644 |
|
2645 | | - 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 |
2646 | | - // are applied recursively to \tcode{Y} and \tcode{Z}, \tcode{S} is $\{ \tcode{Y::h(int)}, \tcode{Z::h(double)} \}$ and |
2647 | | - // overload resolution chooses \tcode{Z::h(double)} |
| 2645 | + 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 |
| 2646 | + // are applied recursively to \tcode{Y} and \tcode{Z}, \tcode{S} is $\{ \tcode{Y::h(int)}, \tcode{Z::h(double)} \}$ and |
| 2647 | + // overload resolution chooses \tcode{Z::h(double)} |
2648 | 2648 | } |
2649 | 2649 | \end{codeblock} |
2650 | 2650 | \end{example} |
|
0 commit comments