samedi 18 juillet 2020

Pointers in cpp

I have next example in book

const int** pp2;
int* p1;
const int n = 13;
pp2 = &p1; // not allowed, but suppose it were
*pp2 = &n; // valid, both const, but sets p1 to point at n
*p1 = 10; // valid, but changes const n

But how expression *pp2=&n can be valid, if pp2 is pointer-to-const?

Aucun commentaire:

Enregistrer un commentaire