Can someone please explain what does int pointer new int10

Can someone please explain what does \" int** pointer = new int*[10] \" mean??? Thanks

Solution

int** pointer = new int*[10]

Here pointer is pointer to an array of 10 pointers;

Each array element of pointer contains address of other variable..

for example

declare two variables x and y;

int x, y;

assign 1st element of array of pointer points to x ,

make 2nd element of array of pointer points to y

pointer[0] = &x; //&gives the address of the variable

pointer[1] = &y;

suppose we want to assign 3rd element of array of pointers point to array for integers , we can assign as below

int arr[] = { 1,2,3,4,5};

pointer[2] = arr ;

like this we can assign 10 array elements of pointer contains address of another variable.

Can someone please explain what does \

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site