int array[10] == int* array = new int[10] ?

I'm just learning C++ for the first time. I have been programing in java for about 2 - 3 years and C for about 1 year. I'm wondering what is the difference between

int array[10];

and

int* array = new int[10];
The 10 integers are placed on the stack in the first case.

In the second case, the 10 integers are allocated on the heap and a pointer to the array is placed on the stack.
What exactly does that mean tough? I never fully understood how the stack and the heap worked.
In the first case, the array will automatically be destroyed/freed after you exit the scope.

In the second case, you will have to delete it manually using delete array; however, the pointer WILL be destroyed after you exit the scope, which means you won't be able to delete the memory if you don't have a pointer to it.
Thanks that helps
Another difference is that the stack is much more limited in size than the heap.
Topic archived. No new replies allowed.