I have a class like this one:
class Test{
public:
Test(string value);
Test(bool value);
};
If I create an object like this:
The type of "Just a test..."
is const char*
. There is a built-in conversion from pointers to bool
which is preferred over the non-built-in conversion from const char*
to std::string
.
The reason that the bool conversion is preferred is because std::string
, while part of the standard library, is not a built-in type like integers, pointers, and booleans. It acts like any other class, and so its conversion constructors are considered only after conversions to built-in types.