operator new[] where size is 0

Regarding http://www.cplusplus.com/reference/new/operator%20new%5B%5D/

what if I have

table = new LinkedList<string>[tableSize];

where tableSize is equal to 0? (LinkedList is a class I created)
What does it do? What does table become? Thank you.

Edit:

In the link it says

"If this argument is zero, the function still returns a distinct non-null pointer on success (although dereferencing this pointer leads to undefined behavior)."

So I guess I'd still have to delete even if the size is 0, right?
Last edited on
While I'd need to look at the standard to be sure, I would have a very high suspicion that yes, you must delete the pointer. It would seem odd to me to have a special exception for when you've allocated an array of size 0.
So I guess I'd still have to delete even if the size is 0, right?

Yes.
Topic archived. No new replies allowed.