我已经定义了一个这样的类
using namespace std;
class foo {
public:
  typedef std::pair< int, int > index;
  bool operator == ( const index &l, const index &r )
  {
    return (l.first == r.first && l.second == r.second);
  }
  void bar()
  {
    index i1;
    i1.first = 10;
    i1.second = 20;
    index i2;
    i2.first = 10;
    i2.second = 200;
    if (i1 == i2)
       cout << "equal\n";
  }
};
但是我在 Windows 中收到此错误
error C2804: binary 'operator ==' has too many parameters
和linux中的这个错误
operator==(const  std::pair<int, int>&, const std::pair<int, int>&)’ must take exactly one argument
我发现这个主题重载 operator== 抱怨“必须只采用一个参数”,并且似乎是类中静态和非静态函数的问题。但是不知道怎么申请this
例如,这是不正确的
  bool operator == ( const index &r )
  {
    return (this->first == r.first && this->second == r.second);
  }
我该如何解决?