[Solved] ==operator overload only on certain occasions


You can’t overload operator== for C strings, because they are pointers and operators can be overloaded if at least one operand is a class or enum. What you can do is create your own comparator function and use it in your code instead of ==:

template<typename T>
bool my_equal(const T& a, const T& b) {
    return a == b;
}

bool my_equal(const char* a, const char* b) {
    return /* your comparison implementation */;
}

Update: you may have to add more overloads to support std::string vs const char* comparisons, as pointed out by TonyD in comments.

4

solved ==operator overload only on certain occasions