By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
457,759 Members | 1,242 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 457,759 IT Pros & Developers. It's quick & easy.

"some_type* p_some_type = new some_type [0]" legal?

P: n/a
is it valid to call new [] to allocate 0 elements? If so, is p_some_type
NULL afterwards?
Jan 24 '07 #1
Share this Question
Share on Google+
1 Reply


P: n/a


On 24 Jan, 15:02, "r.z." <g...@hjkjhk.plwrote:
is it valid to call new [] to allocate 0 elements? If so, is p_some_type
NULL afterwards?
Yes, No.

Allocating 0 elements returns non-NULL pointer. The pointer will be
different each time. It's not legal to dereference the pointer, but it
is legal to pass it to delete[].

Usually this is exactly what you want.

Jan 24 '07 #2

This discussion thread is closed

Replies have been disabled for this discussion.