new keyword?

I am just curious about dynamic alloc and non.

For instance,

1
2
3
4
5
6
7
int a[10000];
int *b[10000];
for(int i = 0; i < 10000; i++)
{
   a[i] = i;
   b[i] = new int(i);
}


what is difference between them?
Last edited on
Does line #2 work fine ie: no error?
Also dynamically allocating memory for an object(pointer) allocates a specific amount of memory to the object from the heap.
So after finishing using the object, you must free the memory with delete, if new was used, or delete[] if it is an array.

Aceix.
Topic archived. No new replies allowed.