|
-
July 28th, 2005, 08:22 PM
#3
Re: Stack vs Heap ??
 Originally Posted by stober
when you use new or malloc() the memory is normally allocated from the heap. When you allocate an object within a function, it goes on the stack
Code:
void foo()
{
int x; <<< x is on the stack
char *ptr = new char[255]; <<< 255 characters are allocated in the heap
but ptr object is on the stack
int array[255]; <<< 255 ints are all on the stack
}
so whats the difrence?
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
|