fork download
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. class String {
  6.  
  7. public:
  8.  
  9. friend String operator+(const String & l, const String & r);
  10.  
  11. String(){}
  12.  
  13. String operator+(const String & lhs)
  14. {
  15. cout << "member" << endl;
  16. }
  17. };
  18.  
  19. String operator+(const String & l, const String & r)
  20. {
  21. cout << "friend" << endl;
  22. }
  23.  
  24. ostream & operator<<(ostream & os, const String & s)
  25. {
  26. return cout << "cout" << endl;
  27. }
  28.  
  29. int main()
  30. {
  31. String one;
  32.  
  33. cout <<(one + one)<<endl;
  34. }
Success #stdin #stdout 0s 16064KB
stdin
Standard input is empty
stdout
member
cout