lundi 16 mars 2015

Confused with pointer and double pointer in the heap


I'm getting confused about pointers and double pointers.


Suppose we have these



int* ptr = new int[2];


Here, ptr has the address of an array of size two in the heap that keeps int data right?



int** ptr = new int* [2];


Here, ptr has the address two pointers in the heap and these two pointers can point to some int data.


Is my thinking here correct?




Aucun commentaire:

Enregistrer un commentaire