DEV Community

Discussion on: The const issue

Collapse
 
loki profile image
Loki Le DEV

I totally agree, by placing the const on the right side we can read from right to left:

int foo;        // integer
int const foo;  // const integer
int* foo;       // pointer to integer
int const* foo; // pointer to constant integer
int& foo;       // reference to int
int const& foo; // reference to constant int
int const* const foo; // constant pointer to constant int
int const& const foo; // constant reference to constant int    
Enter fullscreen mode Exit fullscreen mode
Collapse
 
pgradot profile image
Pierre Gradot • Edited

int const& const foo; doesn't compile in C++.

It is impossible make a reference "points" to another variable.

A 'const reference' means that the reference considers it "points" a const object.