0

X value is constant 5 , and z denote the address of x value . But we don't know address of x value.it show error output why ?

int*z; int const x= 5; z=&x; z++; cout<<z;

16th Sep 2020, 12:13 PM
Suparna Podder
Suparna Podder - avatar
2 Respuestas
+ 1
You have defined value of x constant and after that you created reference variable which is z=&x ; first read the concept of reference if you change the value of z then x will automatically change and you cannot change the value of constant variable so its error.
16th Sep 2020, 12:34 PM
A S Raghuvanshi
A S Raghuvanshi - avatar
0
int* cannot point to const int. You need to declare const pointer e.g. int const* z.
16th Sep 2020, 12:26 PM
你知道規則,我也是
你知道規則,我也是 - avatar