L
linq936
Hi,
I have the following code:
int main(){ /* line 1 */
const int i = 10; /* line 2 */
const int j = 20; /* line 3 */
/* line 4 */
int const * const p = &i; /* line 5 */
const int * const p2 = &j; /* line 6 */
/* line 7 */
(*p2)++; /* line 8 */
(*p)++; /* line 9 */
return 0;
}
Compiler does not complain line 6 and errors out on those
incremental statements of line 8 and 9.
So the declaration on line 5 and line 6 are the same? I mean "int
const * const" and "const int * const" are same?
It is a little hard to grasp how to use "const" in declaration.
Any tip?
I have the following code:
int main(){ /* line 1 */
const int i = 10; /* line 2 */
const int j = 20; /* line 3 */
/* line 4 */
int const * const p = &i; /* line 5 */
const int * const p2 = &j; /* line 6 */
/* line 7 */
(*p2)++; /* line 8 */
(*p)++; /* line 9 */
return 0;
}
Compiler does not complain line 6 and errors out on those
incremental statements of line 8 and 9.
So the declaration on line 5 and line 6 are the same? I mean "int
const * const" and "const int * const" are same?
It is a little hard to grasp how to use "const" in declaration.
Any tip?