fork(2) download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. struct ACE_Time_Value { };
  5. ostream &operator<<(ostream &os, const ACE_Time_Value &) { os << "Apple" ; }
  6. void foo(const ACE_Time_Value &) { cout << "Cherry" << endl; }
  7.  
  8. namespace mine {
  9. ostream &operator<<(ostream &os, const ACE_Time_Value &) { os << "Banana" ; }
  10. void foo(const ACE_Time_Value &) { cout << "Durian" << endl; }
  11.  
  12. void bar() {
  13. ACE_Time_Value t;
  14. ::mine::foo(t); // OK
  15. // cout << "The current time is " <<
  16. // t << endl; // error: ambiguous overload for 'operator<<'
  17. }
  18. }
  19.  
  20. int main() {
  21. mine::bar();
  22. }
Success #stdin #stdout 0s 3456KB
stdin
Standard input is empty
stdout
Durian