What will be printed?

#include <iostream>

using namespace std;

const int &test() {
    static int a=3;
    return a;
}

int main() {
    test()++;
    test()++;
    cout << test() << endl;
    return 0;
}
Explanation
The code will not compile since test() returns a reference to an integer constant, to which an increment operator cannot be applied.

Follow CodeGalaxy

Mobile Beta

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