C ++: implicit conversion order

I have a (member-) fuction overloaded as follows:

bool foo(bool);
int foo(int);
float foo(float);
...
std::string foo( std::string const&);

for several built-in types, but not for const char*. The call foo("beauty is only skin-deep");, to my great surprise, is called the bool variant of the foo function. This leads to my questions:

QUESTION: Is there a well-defined implicit conversion order for built-in types

NO QUESTION: How to avoid implicit conversion. How evil is an implicit transformation ....

EDIT: remove the implicit conversion question for custom questions

+4
source share
1 answer

: http://en.cppreference.com/w/cpp/language/implicit_cast

pointer → bool - " " ( if ()), " "

'const char *' → std::string " " , std::string .

, fun (const char *) fun (bool) fun (std::string)

+7

All Articles