title: Comparing nodes in a linked list by reference
body: <p>I'm trying to compare nodes in two separate linked lists by reference and not value.
  My implementation of linked list is as under</p>
  
  <pre><code>struct node{
      node(char data):data(data), next(nullptr){}
      char data;
      node* next;
  };
  
  class slist{
      node* head;
  public:
      slist(node* head):head(head){}
  
      node*&amp; getHead(){
          return head;
      }
      void insert(char item){
          node* p = new node(item);
          if(head == nullptr){
              head = p;
              return;
          }
          p-&gt;next = head;
          head = p;
  
      }
  </code></pre>
  
  <p>This is the overloaded operator that I use to compare two nodes by reference.</p>
  
  <pre><code>bool operator==(node*&amp; p, node*&amp; q){
      if(p-&gt;data == q-&gt;data) return true;
      return false;
  }
      static node* compare(node*&amp; p, node*&amp; q){
          if(p == nullptr || q == nullptr) return nullptr;
          node* current1 = p;
          node* current2 = q;
  
          while(current1 != nullptr){
              while(current2 != nullptr){
                  if(current1 == current2) return current1;
                  current2 = current2-&gt;next;
              }
              current1 = current1-&gt;next;
          }
          return nullptr;
  
      }
  };
  </code></pre>
  
  <p>The driver code is as follows:</p>
  
  <pre><code> bool operator==(node*&amp; p, node*&amp; q){
          if(p-&gt;data == q-&gt;data) return true;
          return false;
      }
  
  static node* intersection(node*&amp; p, node*&amp; q){
      if(p == nullptr || q == nullptr) return nullptr;
      node* current1 = p;
      node* current2 = q;
  
      while(current1 != nullptr){
          while(current2 != nullptr){
              if(current1 == current2) return current1;
              current2 = current2-&gt;next;
          }
          current1 = current1-&gt;next;
      }
      return nullptr;
  
  }
  </code></pre>
  
  <p>The error that I keep getting is as follows:</p>
  
  <pre><code>error: overloaded 'operator==' must be a binary operator (has 3 parameters)
      bool operator==(node*&amp; p, node*&amp; q){
           ^
  </code></pre>