Alex Rivera | Logout

int *array = new int[n]; what is this function actually doing?

Asked 2011-04-25T08:16:02.860
30

I am confused about how to create a dynamic defined array:

 int *array = new int[n];

I have no idea what this is doing. I can tell it's creating a pointer named array that's pointing to a new object/array int? Would someone care to explain?

Edit
Report

1 Answer

2

It allocates space on the heap equal to an integer array of size N, and returns a pointer to it, which is assigned to int* type pointer called "array"

answered 2011-04-25T08:19:59.727

Your Answer