Take the 2-minute tour ×  I was trying to clean up some code
that uses char* with std::string and ran into a problem that is
illustrated by the following code.  void Foo( int xIn , const
std::string & fooIn )     std::cout << "string argument version
called \n";  void Foo( int xIn ,  bool flagIn = true )
std::cout << "bool argument version called \n";  int main()
int x = 1;     Foo( x , "testing" );     return 0;  When I run
the program I get bool argument version called. Is a char* to
bool conversion preferred over char* to const std::string& or is
Visual Studio 2008 playing tricks on me ?  share|improve this
question Look at stackoverflow.com/questions/663724/… –  Sumudu
Fernando Dec 2 '11 at 16:14 Cleaned up the formatting a bit &
removed irrelevant Windows stuff. –  John Dibling Dec 2 '11 at
16:14 I normally avoid implicit conversion in C++ because it is
so easy to get some unexpected behaviour (bug). –  Giorgio Dec 2
'11 at 17:54 add comment  3 Answers  up vote 27 down vote
accepted  Surprising a