mercredi 23 août 2017

Confusion regarding the usage of const,pointer and type alias [duplicate]

This question already has an answer here:

Consider the following code,

const char *pstring;//pstring is a pointer to char
char *const pstring1;//pstring1 is a const pointer to char

Now consider the following example of type alias,

typedef char *pstring;//pstring is synonym for pointer to char
const pstring cstr = 0;

If we interpret pstring in the second statement as char*,then

how is cstr a const pointer to char and not a pointer to const char?

Aucun commentaire:

Enregistrer un commentaire