title: C++ template class error with operator ==
body: <p>Error:<br>
  error C2678: binary '==' : no operator found which takes a left-hand operand of type 'const entry' (or there is no acceptable conversion)</p>
  
  <p>The function:  </p>
  
  <pre><code>template &lt;class T, int maxSize&gt;
  int indexList&lt;T, maxSize&gt;::search(const T&amp; target) const
  {
      for (int i = 0; i &lt; maxSize; i++)  
          if (elements[i] == target)   //ERROR???
              return i;       // target found at position i
  
      // target not found
      return -1;
  }
  </code></pre>
  
  <p><a href="http://www2.cs.uregina.ca/%7Emouhoubm/=teaching/=cs170/=indexList/indexList.h" rel="nofollow noreferrer">indexList.h</a><br>
  <a href="http://www2.cs.uregina.ca/%7Emouhoubm/=teaching/=cs170/=indexList/indexList.cpp" rel="nofollow noreferrer">indexList.cpp</a> </p>
  
  <p>Is this suppose to be an overloaded operator? Being a template class I am not sure I understand the error?</p>
  
  <p>Solution-
  The overload function in the class now declared const:</p>
  
  <pre><code>//Operators
  bool entry::operator == (const entry&amp; dE)  const &lt;--
  {
      return (name ==dE.name);
  
  }
  </code></pre>