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

struct A;

int operator+(const A&, const A&) {
    return 3;
}

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

int main() {
    A a, b;
    std::cout << a + b;
}
Explanation
13.3.1.2 Operators in expressions
...
The set of candidate functions for overload resolution is the union of the member candidates, the non-member candidates, and the built-in candidates. The argument list contains all of the operands of the operator. The best function from the set of candidate functions is selected according to 13.3.2 and 13.3.3.119)

Следи за CodeGalaxy

Мобильное приложение Beta

Get it on Google Play
Обратная Связь
Cosmo
Зарегистрируйся сейчас
или Подпишись на будущие тесты