fork download
  1. #include <iostream>
  2. #include <vector>
  3.  
  4. struct MyNum
  5. {
  6. int num;
  7. MyNum(int i) : num(i) {}
  8. bool operator<(const MyNum& rhs) const
  9. {
  10. return num < rhs.num;
  11. }
  12. bool operator==(const MyNum& rhs) const
  13. {
  14. return num == rhs.num;
  15. }
  16. };
  17.  
  18. void test(const std::vector<MyNum>& a, const std::vector<MyNum>& b)
  19. {
  20. if (a == b)
  21. {
  22. std::cout << "a == b\n";
  23. }
  24. else if (a < b)
  25. {
  26. std::cout << "a < b\n";
  27. }
  28. else if (a > b)
  29. {
  30. std::cout << "a > b\n";
  31. }
  32. }
  33.  
  34. int main()
  35. {
  36. std::vector<MyNum> a1{ 1,2,3,4,5 };
  37. std::vector<MyNum> a2{ 1,2,3,4,5 };
  38. std::vector<MyNum> b1{ 1,2,3,4,6 };
  39. std::vector<MyNum> b2{ 1,2,3,4,4 };
  40. test(a1, a2);
  41. test(a1, b1);
  42. test(a1, b2);
  43. return 0;
  44. }
  45.  
Success #stdin #stdout 0s 15240KB
stdin
Standard input is empty
stdout
a == b
a < b
a > b