What will the following code print?
#include <iostream>

struct A {
    operator int() {
        return 1;
    };
    
    operator double() {
        return 2.0;
    }
};

int main() {
    A a;
    
    int i = a;
    float x = a;
    x += i;
    
    std::cout << x;
}
Explanation
Conversion "a" to the float type is ambiguous. The "double()" operator, in this case, has no advantages over the "int()".
operator
13.3.3 Best Viable Function

Follow CodeGalaxy

Mobile Beta

Get it on Google Play
Send Feedback
Cosmo
Sign Up Now
or Subscribe for future quizzes