|
-
May 2nd, 2002, 01:56 PM
#6
Thread Starter
Dazed Member
Well lets first define what the main difference is between a class(which is a refrence type) and a structure(which is a value type) is. For instance an integer or byte has a fixed number of bytes regardless of the actual value held by the variable. So these are normally stored on the stack. For refrence types such as vectors
memeory is allocated dynamically so they are commonly stored on the heap.
As i understand it, the main reason for this seperation is that when a process needs to retrieve a variable it has to search the stack, looking for the variable specified. Now even with complex algorithms the search might take a long perod of time if the stack included large dynamic items such as collections and sets. So a refrence(or pointer) is just stored in a memory address that resides on the stack which points to where the dynamic type resides on the heap.
Last edited by Dilenger4; May 2nd, 2002 at 10:40 PM.
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
|