4 ms·
I use the "right-to-left" style myself. To me, the qualifier (in this case, const), applies to the item to the right. This could be confusing: const char
by spc476 2y ago
I use the "right-to-left" style myself. To me, the qualifier (in this case, const), applies to the item to the right. This could be confusing:
const char *const ptr;
The first const applies to the char, but the second one to the pointer itself. Being consistent:
char const *const ptr;
The first const applies to the item to its left---char. The second const applies to the item to its left---the pointer. To recap:
char *ptr1; // modifiable pointer to modifiable data
char const *ptr2; // modifiable pointer to const data
char *const ptr3; // const pointer to modifiable data
char const *const ptr4; // const pointer to const data