Why is p turning out const, instead of the characters pointed to?

Q

I've got the declarations
typedef char *charp;
const charp p;

Why is p turning out const, instead of the characters pointed to?

✍: Guest

A

typedef substitutions are not purely textual.In the declaration
const charp p;
p is const for the same reason that const int i declares i as const. The typedef'ed declaration of p does not ``look inside'' the typedef to see that there is a pointer involved.

2016-01-04, 1102👍, 0💬