Note that there are some explanatory texts on larger screens.

plurals
  1. POerror C2679: binary '==' : no operator found which takes a right-hand operand of type
    text
    copied!<p>I am having trouble getting my homework assignment to work properly. I have overloaded my '==' operator, but still I get this error. Not really sure why it's being thrown or how to fix it. Any help would be appreciated.</p> <p>Here is my algorithm:</p> <pre><code>/* Performs a recursive binary search on the given array. It returns * the index of the found value, -1 otherwise. */ template &lt;typename T, typename V&gt; int binarySearch(T* list[], const V&amp; searchValue, const int firstIndex, const int lastIndex) { if (firstIndex &lt;= lastIndex) { int mid = (firstIndex + lastIndex) / 2; //mid point of list. if (searchValue == *list[mid]) return mid; // found value. else if (searchValue &lt; *list[mid]) return binarySearch(list, firstIndex, mid - 1, searchValue); else return binarySearch(list, mid + 1, lastIndex, searchValue); } return -1; //failed to find value } </code></pre> <p>Debugger says this line in main is where the error originates:</p> <pre><code>// Search the person array. cout &lt;&lt; "Searching people array for person with name = 'Mickey Mouse': " &lt;&lt; (binarySearch(person, "Mickey Mouse", 0, 7) != -1? "found it." : "did not find it.") &lt;&lt; endl; </code></pre> <p>Here is my person class header file showing the overloaded operator:</p> <pre><code>#ifndef PERSON_H #define PERSON_H #include &lt;string&gt; #include &lt;iostream&gt; using namespace std; namespace P03 { class Person {...}; // end Person /* Displays a Person to the screen. * Calls the toString() method. */ ostream&amp; operator &lt;&lt;(ostream&amp; out, const Person&amp; person) { return out &lt;&lt; person.toString(); } /* The following relational operators compare two instances of the * Person class. The comparison is made on the compound value of: * &lt;lastName&gt;&lt;space&gt;&lt;firstName&gt; */ bool operator ==(const Person&amp; lhs, const Person&amp; rhs) { return lhs.getName() == rhs.getName(); } /*other operators*/ ... } // end namespace P03 #endif </code></pre> <p>Not sure if more of my code is needed. I will update if need be.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload