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
Зарегистрируйся сейчас
или Подпишись на будущие тесты