title: C++ Operator Overload - call function to get value inside overload
body: <p>Is there a way I can call an operator overload in C++ and call the parameter's function during the comparison?</p>
  
  <p>For example:</p>
  
  <pre><code>class MyClass{
    private:
      int x;
      int y;
    public:
      MyClass(int x, int y);
      int getX();
      int getY();
      bool operator &lt; (const MyClass &amp;other) const {
          return (x &lt; other.getX()); //this does not work!
          // this would work, though, if x was public:
          // return x &lt; other.x;
      }
  };
  </code></pre>
  
  <p>Basically, where I call other.getX(), how can I make it return its own x-value through a function to compare to the local one, instead of having to make x public? Is there a way of doing that?</p>
  
  <p>Thanks for all your help!</p>