struct Foo {
void setBar(bool bar_) { bar = bar_; }
bool bar;
};
int main() {
Foo f;
f.setBar("true");
}
The above code compiles successfully due to type conversion, even though a char array is passed where a bool
is expected.
Is it possible to cause this code to fail compilation? (C++03 solution preferred, since the compiler at my workplace is ancient.)
I have looked at the following related questions on StackOverflow, but they don't quite address this problem. Preventing implicit conversion in C++, Why does the compiler choose bool over string for implicit typecast of L""?