Reputation: 119
In my code i have encountered 37 errors of the same type c2678; binary 'operator' : no operator defined which takes a left-hand operand of type 'type' (or there is no acceptable conversion)
I am trying to remove the error by overloading the == operator, by including the STL "utility". http://msdn.microsoft.com/en-us/library/86s69hwc(v=vs.80).aspx http://en.wikibooks.org/wiki/C%2B%2B_Programming/Operators/Operator_Overloading
But still this doesnt works. Any help is appreciated.
Upvotes: 0
Views: 247
Reputation: 254751
That header provides overloads of operator==
for some standard types, but it won't magically overload it for your own types. If you want your types to be equality-comparable, then you'll have to overload the operator yourself, for example:
bool operator==(my_type const & a, my_type const & b) {
return a.something == b.something
&& a.something_else == b.something_else;
}
// You'll probably want this as well
bool operator!=(my_type const & a, my_type const & b) {
return !(a == b);
}
Upvotes: 1