Archived

This topic is now archived and is closed to further replies.

the difference between new[] & new?

This topic is 5973 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

with the ''new'' operator, you allocate memory and get a pointer to it:

int* i = new int;

now, if you want to allocate an array of 100 int''s:

int* iv = new int [100];

(the size you allocate must be a constant/const variable)

..and make sure that you delete the second one like this:

delete [] iv; //delete the whole block

Share this post


Link to post
Share on other sites