Click here to Skip to main content
15,914,221 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Accessing CEdit Member Functions Inside CEditView ::MFC Pin
Alex Cramer10-Apr-02 18:25
Alex Cramer10-Apr-02 18:25 
GeneralClasses in DLL Pin
10-Apr-02 16:44
suss10-Apr-02 16:44 
GeneralRe: Classes in DLL Pin
10-Apr-02 17:36
suss10-Apr-02 17:36 
GeneralRe: Classes in DLL Pin
Gunnar Bolle10-Apr-02 23:44
Gunnar Bolle10-Apr-02 23:44 
GeneralRe: Classes in DLL Pin
jan larsen11-Apr-02 2:17
jan larsen11-Apr-02 2:17 
GeneralRe: Classes in DLL Pin
Jack Hui11-Apr-02 5:30
Jack Hui11-Apr-02 5:30 
Generalheap, stack Pin
NicholasCougar10-Apr-02 16:25
NicholasCougar10-Apr-02 16:25 
GeneralRe: heap, stack Pin
Paul M Watt10-Apr-02 16:35
mentorPaul M Watt10-Apr-02 16:35 
When you create an object on the stack, you are basically creating a variable in the current stack frame in which you are operating. Stack varaibles automatically go away when you exit the function call that they were defined in.

The heap is where dynamic memory is allocated from. When you declare an object on the heap, you have to allocate memory for it, usually with new or malloc, or in the case of the windows API GlobalAlloc. The pointer that you recieve from one of these allocations will not be destroyed until you explicitly destroy it. You can destroy heap memory that you have previously allocated with delete, free, or GlobalFree, each of these calls corresponding to the allocators that I mentioned earlier.

The advantages of the stack is that you do not have to manage the memory, just declare the variable and start using it. It will clean up after itself when the function exits. The disadvantage is that you have to know how much memory that you need at compile time, and the variables that you declare are not persistent outside of the function that they are described in.

The advantage of the heap is that you can decide how much memory that you need at runtime, and the variables will persist as long as you need them.


Checkout my Guide to Win32 Paint for Intermediates
GeneralRe: heap, stack Pin
James R. Twine12-Apr-02 10:12
James R. Twine12-Apr-02 10:12 
GeneralRe: heap, stack Pin
Ravi Bhavnani12-Apr-02 10:49
professionalRavi Bhavnani12-Apr-02 10:49 
GeneralRe: heap, stack Pin
James R. Twine12-Apr-02 15:56
James R. Twine12-Apr-02 15:56 
GeneralFormatting rebars Pin
funbag10-Apr-02 16:16
funbag10-Apr-02 16:16 
GeneralRe: Formatting rebars Pin
wangyiming12-Apr-02 3:47
wangyiming12-Apr-02 3:47 
GeneralRe: Formatting rebars Pin
wangyiming12-Apr-02 3:50
wangyiming12-Apr-02 3:50 
Generalstatic in class Pin
NicholasCougar10-Apr-02 15:46
NicholasCougar10-Apr-02 15:46 
GeneralRe: static in class Pin
Christian Graus10-Apr-02 16:06
protectorChristian Graus10-Apr-02 16:06 
GeneralRe: static in class Pin
moliate10-Apr-02 20:44
moliate10-Apr-02 20:44 
GeneralRe: static in class Pin
James R. Twine12-Apr-02 10:17
James R. Twine12-Apr-02 10:17 
GeneralRe: static in class Pin
moliate12-Apr-02 12:52
moliate12-Apr-02 12:52 
GeneralRe: static in class Pin
James R. Twine12-Apr-02 20:15
James R. Twine12-Apr-02 20:15 
GeneralVisual Studio .net offer Pin
CodeProjectSQ10-Apr-02 14:10
CodeProjectSQ10-Apr-02 14:10 
GeneralRe: Visual Studio .net offer Pin
CodeProjectSQ12-Apr-02 16:06
CodeProjectSQ12-Apr-02 16:06 
GeneralTab Contol on a dialog box Pin
10-Apr-02 13:07
suss10-Apr-02 13:07 
GeneralRe: Tab Contol on a dialog box Pin
Shog910-Apr-02 13:30
sitebuilderShog910-Apr-02 13:30 
Generalquick question on color Pin
jafrazee10-Apr-02 12:30
jafrazee10-Apr-02 12:30 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.