It might be calling the constructor implicitly
class FileName{public: FileName(const char* name){ cout << "Constructor called"; }; bool operator==(const FileName& rhs){ cout << "Equality operator called"; return true; } };int main(){ FileName f = "foo"; f == "bar";}
The first line in main() calls the constructor implicitly
The second line tries to compare f to "bar", and it does so by implicitly constructing "bar" into a FileName object and then calling the == operator.
Now have a look at this:
http://stackoverflow.com/questions/1384007/conversion-constructor-vs-conversion-operator-precedence
Does this explain the behavior you're getting?
Edit: I get a compiler error when I add a cast operator to const char*, as the call is ambiguous. Adding the explicit keyword to the constructor solves the problem as then the compiler can only interpret f == "bar" as a char pointer comparison.