fork download
  1. #include <iostream>
  2.  
  3. class foo {
  4. public:
  5. foo() : i(1), j(2) {}
  6.  
  7. int i;
  8. int j;
  9. bool operator<(const foo& val) {
  10. std::cout << "memba\n";
  11. return i<val.i;
  12. }
  13. };
  14.  
  15. bool operator<(const foo& lhs, const foo& rhs) {
  16. std::cout << "free\n";
  17. return lhs.j < rhs.j;
  18. }
  19.  
  20. int main()
  21. {
  22. foo f1, f2;
  23. bool b1 = f1 < f2;
  24.  
  25. foo const f3;
  26. bool b2 = f3 < f2;
  27.  
  28. return b1 + b2;
  29. }
  30.  
Success #stdin #stdout 0s 2828KB
stdin
Standard input is empty
stdout
memba
free