|
-
July 29th, 2005, 03:43 AM
#5
Re: Stack vs Heap ??
 Originally Posted by Kheun
The difference can be identified from the usage of the operator new. When it is used, you will be allocating memory from the heap and you need a pointer to store the address. As the memory from the stack, the variable has to be declared within a function without using operator new.
...and calling the constructor too as it happens. Heap is be to totally your resposibility. What you allocate on to it, is your responsibility to be deleted once you are done with it. Else you get into a condition know as memory leaks which could be very un-healthy for you. Try allocations on stack as much as possible...on heap? only when you need it and u are sure of what you are doing.
Can you help me with my homework assignment?, Before you post!, Use code tags, How to post!, Codeguru technical FAQs, C++ FAQ Lite, Stroustrup: C++ Style and Technique FAQ, Guru of the Week, Comeau C and C++ FAQs, Comeau C++ Templates FAQs, CUJ @ DDJ, Spam threshold
My Blogs : Learning C++ is fun | Abnegator's reflections
Open Threads : C++ Aha! Moments | Nature of work in C++?
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|