cplusplus
.com
TUTORIALS
REFERENCE
ARTICLES
FORUM
C++
Tutorials
Reference
Articles
Forum
Forum
Beginners
Windows Programming
UNIX/Linux Programming
General C++ Programming
Lounge
Jobs
Forum
Beginners
Deallocating memory
Deallocating memory
Jul 22, 2011 at 7:46am UTC
toexii
(79)
1
2
int
* pi =
new
int
[5];
delete
[] pi;
Before deleting pi, it is a pointer to the first int of the array of ints in the memory. pi Does not know to how many objects(ints) it points, right? Then how can the delete[] statement free all the memory(5 ints) that pi points to?
Jul 22, 2011 at 9:23am UTC
closed account (
DSLq5Di1
)
http://www.parashift.com/c%2B%2B-faq-lite/freestore-mgmt.html#faq-16.14
Jul 22, 2011 at 9:30am UTC
toexii
(79)
Thanks, the explanation is a bit over my head at the moment, but it's nice to know that it's not just "magic".
Topic archived. No new replies allowed.