hi all~
we can build dynamic array just like this:
and i wonder what if num = 0 ? does arr really holds memory allocated or not ?Code:int num = 10;
int* arr = new int[num];
Printable View
hi all~
we can build dynamic array just like this:
and i wonder what if num = 0 ? does arr really holds memory allocated or not ?Code:int num = 10;
int* arr = new int[num];
Try it for yourself to see what happens.
>and i wonder what if num = 0 ?
You get a pointer to an array of size 0. The pointer is valid, but you can't dereference it.
>does arr really holds memory allocated or not ?
No, it "points to" memory allocated. :)