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 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

Follow CodeGalaxy

Mobile Beta

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