Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why is this const const const declaration valid

Tags:

People also ask

What is const int * const?

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.

What is the difference between const int and int const?

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.

What is the difference between int const * p1 and int * const p1 explain with simple program?

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.

What does const int mean in C++?

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.