I want to use classas keyin map, so I overload operator+. It works well if I overload it as a friend function. When I overload it as a member function inside a class, it causes a compilation error.
error C2678: binary '<': an operator was not found that accepts a left operand of type 'const Syl' (or there is no acceptable conversion) '.
In detail, this does not compile and does not generate a compilation error:
Syl.h
bool operator< (const Syl& rhs);
Syl.cpp
bool Syl::operator< (const Syl& rhs) { return false; }
While this is compiling.
Syl.h
friend bool operator< (const Syl& lhs, const Syl& rhs);
Syl.cpp
bool operator< (const Syl& lhs, const Syl& rhs) { return false; }
I do not know why. I know that the <operator is binary, but anyway, to overload it as a member of a function?