Reputation: 24675
Is it true that having:
int* p = new int;
and:
int* p1 = new int[5]();
in case of p1 there will be extra info stored?
Upvotes: 2
Views: 91
Reputation: 76755
Yes, there might be.
I recommend you read the following to items from C++-faq :
A relevant quote extracted from the first link :
The run-time system stores the number of objects, n, somewhere where it can be retrieved if you only know the pointer, p. There are two popular techniques that do this. [...]
- Over-allocate the array and put n just to the left of the first Fred object.
- Use an associative array with p as the key and n as the value
Upvotes: 3