C++: call original definition of operator equals

Posted by Luis Daniel on Stack Overflow See other posts from Stack Overflow or by Luis Daniel
Published on 2013-10-21T03:45:26Z Indexed on 2013/10/21 3:53 UTC
Read the original article Hit count: 242

I am overloading the operator equals (==) as show bellow:

#include <string>
#include <algorithm>

bool operator == (std::string str1, std::string str2) {
    std::transform(str1.begin(), str1.end(), str1.begin(), ::tolower);
    std::transform(str2.begin(), str2.end(), str2.begin(), ::tolower);
    return (str1 == str2);
}

but, the problem appear on line return (str1 == str2), because operator == is called recursively. So, how can I call the original definition for operator equals (not the overloaded) ?

Best regards

© Stack Overflow or respective owner

Related posts about c++

Related posts about operator-overloading