I am defining multiple overloads of the assignment operator as follows:
Foo.h
class Foo
{
private:
bool my_bool;
int my_int;
Daniel is right.
The short answer is that std::string
is not a built-in type and, as such, doesn't get any magical preferential treatment. And that, unfortunately, the type of a string literal such as "hi world"
is not std::string
, but a pointer type which more easily converts to the built-in type bool
than to the "user-defined"† type std::string
.
Basically, the answer is: welcome to C++.
† Yes, I know, it's from the standard library and, no, it doesn't matter.