Given an example of passing arguments by references. In which rows compilation will fail?
void foo(int const* x, int* const y){
    int a;
    *x = 5; //1
    x = &a; //2
    *y = 5; //3
    y = &a; //4
int main()
    int x,y;
In order to properly answer this question, you can use a simple rule. It is necessary to read the classified function argument from right to left:
int const * x // x is a pointer to a const int (can not change the value of the variable to which the pointer points // 1)
int * const y // y is a constant pointer to int (can not change the value of the pointer // 4)

Следи за CodeGalaxy

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

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