Will the following code compile? If no - which lines will compilation errors occur in?
Before C++14 standard.
int main()
{
    const int* i = int(); // 1
    int const* j = int(); //2
    int* const k = int(); //3
    int* l(); //4

    ++i; //5
    ++j; //6
    ++k; //7
    ++*k; //8
    ++l; //9
}
Explanation
Compilation errors will occur in lines:
3: error: increment of read-only variable ‘k’: constant pointer incrementation attempt
5: error: lvalue required as increment operand: function name increment attempt.

Added new question https://codegalaxy.io/courses/cplusplus/questions/335c0852522911e98647d663bd873d93/c-plus-plus-will-the-following-code-compile

2019 Mar 29, 1:59:36 PM

@Tensor but for C++14 standard, you are completely right - https://ideone.com/14sDSB . Changed question, thanks)

2019 Mar 29, 10:42:09 AM

@Tensor you can check it here https://ideone.com/O32aMO

2019 Mar 29, 10:39:44 AM

Can not initialize const* int with an rvalue

2019 Mar 27, 6:41:58 PM

Следи за CodeGalaxy

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

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