hello i cannot understand whats the benefit of saying that
rather sayingi know that new allocates memmory but please tell me the different of the above codes
The first is a compile error.
Regardless, if you really meant a pointer, then the difference is that
- You aren't limited to stack space (~1 MB usually).
- The allocated storage won't be reclaimed as the function ends (extended lifetime; but comes with the disadvantage that you have to manually deallocate that).
- You can dynamically specify size (you can only specify the amount of storage to reserve on the stack with something that is known at compile time).
Originally Posted by Adak
Originally Posted by Salem