How to interpret a declaration when you have a type (char) pointer (*) and a const keyword?

I know the following sequences:

  • const char* - mutable pointer to immutable character / strin
  • char* const is an immutable pointer, but the contents of the location at which it points are changed.
  • const char* const - an immutable pointer to an immutable character / string.
  • char* - completely permissive.

However, we must interpret the following:

char const *

Is there a way to intuitively understand what 1, 2 and “new” mean, or should we learn by heart.

+4
source share
2 answers

The rule of thumb is "read in reverse order." This answer explains it well.

+2

const char *

+1

All Articles