fork(3) download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. namespace A
  5. {
  6. void f(double x){cout<<"A::f(double)\n";}
  7.  
  8. void f(string s){cout<<"A::f(string)\n";}
  9.  
  10. namespace B
  11. {
  12. using A::f;
  13. void f(int x){cout<<"B::f\n";}
  14.  
  15. void call()
  16. {
  17. f(10); // calls B::f, expected
  18. f(10.5); // calls B::f, why??
  19. string s="Hi";
  20. f(s); // error, why??
  21. }
  22. }
  23. }
  24.  
  25. int main() {
  26. A::B::call();
  27. // your code goes here
  28. return 0;
  29. }
Success #stdin #stdout 0s 3428KB
stdin
Standard input is empty
stdout
B::f
A::f(double)
A::f(string)