const int* const is a constant pointer to constant integer This means that the variable being declared is a constant pointer pointing to a constant integer. Effectively, this implies that a constant pointer is pointing to a constant value.
const int * And int const * are the same. const int * const And int const * const are the same. If you ever face confusion in reading such symbols, remember the Spiral rule: Start from the name of the variable and move clockwise to the next pointer or type. Repeat until expression ends.
In C programming language, *p represents the value stored in a pointer and p represents the address of the value, is referred as a pointer. const int* and int const* says that the pointer can point to a constant int and value of int pointed by this pointer cannot be changed.
The const keyword specifies that a variable's value is constant and tells the compiler to prevent the programmer from modifying it. // constant_values1.cpp int main() { const int i = 5; i = 10; // C3892 i++; // C2105 }
A friend asked me to explain why
const const const const const int const i = 0;
is valid syntax. I declined to have any thoughts on the subject. Though I'm curious if it is just a grammar thing?
Edit. Tag is C++, my friend was referencing gcc, so I should probably add the C tag.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With