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];
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];
Never end on learning~
Try it for yourself to see what happens.
FAQ
"The computer programmer is a creator of universes for which he alone is responsible. Universes of virtually unlimited complexity can be created in the form of computer programs." -- Joseph Weizenbaum.
"If you cannot grok the overall structure of a program while taking a shower, you are not ready to code it." -- Richard Pattis.
>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.
My best code is written with the delete key.