#include <iostream>
#include <string>
struct mystruct{
mystruct(std::string s){
std::cout<<__FUNCTION__ <<" String "<<s;
}
explicit mystruct(bool s) {
std::cout<<__FUNCTION__<<" Bool "<<s;
}
};
int main()
{
const char* c ="hello";
mystruct obj(c);
return 0;
}
output:
mystruct Bool 1
- Why
const char*implicitly converted toboolrather thanstd::string, though constructor requiresexplicittype ? - How the implicit conversion priority applies here?