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 Answers
+ 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