|
296 | 296 | #include <string>
|
297 | 297 |
|
298 | 298 | struct C {
|
299 |
| - std::string s; // \tcode{std::string} is the standard library class\iref{string.classes} |
| 299 | + std::string s; // \tcode{std::string} is the standard library class\iref{string.classes} |
300 | 300 | };
|
301 | 301 |
|
302 | 302 | int main() {
|
|
2548 | 2548 |
|
2549 | 2549 | void h()
|
2550 | 2550 | {
|
2551 |
| - AB::g(); // \tcode{g} is declared directly in \tcode{AB}, therefore \tcode{S} is $\{ \tcode{AB::g()} \}$ and \tcode{AB::g()} is chosen |
| 2551 | + AB::g(); // \tcode{g} is declared directly in \tcode{AB}, therefore \tcode{S} is $\{ \tcode{AB::g()} \}$ and \tcode{AB::g()} is chosen |
2552 | 2552 |
|
2553 |
| - AB::f(1); // \tcode{f} is not declared directly in \tcode{AB} so the rules are applied recursively to \tcode{A} and \tcode{B}; |
2554 |
| - // namespace \tcode{Y} is not searched and \tcode{Y::f(float)} is not considered; |
2555 |
| - // \tcode{S} is $\{ \tcode{A::f(int)}, \tcode{B::f(char)} \}$ and overload resolution chooses \tcode{A::f(int)} |
| 2553 | + AB::f(1); // \tcode{f} is not declared directly in \tcode{AB} so the rules are applied recursively to \tcode{A} and \tcode{B}; |
| 2554 | + // namespace \tcode{Y} is not searched and \tcode{Y::f(float)} is not considered; |
| 2555 | + // \tcode{S} is $\{ \tcode{A::f(int)}, \tcode{B::f(char)} \}$ and overload resolution chooses \tcode{A::f(int)} |
2556 | 2556 |
|
2557 |
| - AB::f('c'); // as above but resolution chooses \tcode{B::f(char)} |
| 2557 | + AB::f('c'); // as above but resolution chooses \tcode{B::f(char)} |
2558 | 2558 |
|
2559 |
| - AB::x++; // \tcode{x} is not declared directly in \tcode{AB}, and is not declared in \tcode{A} or \tcode{B}, so the rules |
2560 |
| - // are applied recursively to \tcode{Y} and \tcode{Z}, \tcode{S} is $\{ \}$ so the program is ill-formed |
| 2559 | + AB::x++; // \tcode{x} is not declared directly in \tcode{AB}, and is not declared in \tcode{A} or \tcode{B}, so the rules |
| 2560 | + // are applied recursively to \tcode{Y} and \tcode{Z}, \tcode{S} is $\{ \}$ so the program is ill-formed |
2561 | 2561 |
|
2562 |
| - AB::i++; // \tcode{i} is not declared directly in \tcode{AB} so the rules are applied recursively to \tcode{A} and \tcode{B}, |
2563 |
| - // \tcode{S} is $\{ \tcode{A::i}, \tcode{B::i} \}$ so the use is ambiguous and the program is ill-formed |
| 2562 | + AB::i++; // \tcode{i} is not declared directly in \tcode{AB} so the rules are applied recursively to \tcode{A} and \tcode{B}, |
| 2563 | + // \tcode{S} is $\{ \tcode{A::i}, \tcode{B::i} \}$ so the use is ambiguous and the program is ill-formed |
2564 | 2564 |
|
2565 |
| - 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 |
2566 |
| - // are applied recursively to \tcode{Y} and \tcode{Z}, \tcode{S} is $\{ \tcode{Y::h(int)}, \tcode{Z::h(double)} \}$ and |
2567 |
| - // overload resolution chooses \tcode{Z::h(double)} |
| 2565 | + 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 |
| 2566 | + // are applied recursively to \tcode{Y} and \tcode{Z}, \tcode{S} is $\{ \tcode{Y::h(int)}, \tcode{Z::h(double)} \}$ and |
| 2567 | + // overload resolution chooses \tcode{Z::h(double)} |
2568 | 2568 | }
|
2569 | 2569 | \end{codeblock}
|
2570 | 2570 | \end{example}
|
|
0 commit comments