Strange implicit conversions with the ternary operator
问题 I have the following code: class A { public: operator int() const { return 5; } }; class B { public: operator int() const { return 6; } }; int main() { A a; B b; int myInt = true ? a : b; return 0; } Attempting to compile that code with Visual Studio 2017 RC results in the following error: error C2446 : : : no conversion from B to A note: No user-defined-conversion operator available that can perform this conversion, or the operator cannot be called ...which is surprising because I would