Why is the conversion constructor not called implicitly for i2?
class NumString
{
public:
NumString(const char* s)
{
}
int operator*( int i)
{
return 42;
}
};
int main(void)
{
int i1 = (NumString) "string" * 2; //OK
int i2 = "string" * 2; //ERROR
}
Because the compiler doesn’t invoke user-defined conversions where there aren’t any user-defined types involved.