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.

Слідкуй за CodeGalaxy

Мобільний додаток Beta

Get it on Google Play
Зворотній Зв’язок
Продовжуйте вивчати
тести з C++
Cosmo
Зареєструйся Зараз
або Підпишись на майбутні тести