Click here to Skip to main content
15,912,021 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Where to put MFC DLL's Pin
User 988520-Nov-02 13:13
User 988520-Nov-02 13:13 
GeneralRe: Where to put MFC DLL's Pin
Christian Graus20-Nov-02 13:16
protectorChristian Graus20-Nov-02 13:16 
GeneralRe: Where to put MFC DLL's Pin
Jim A. Johnson20-Nov-02 12:38
Jim A. Johnson20-Nov-02 12:38 
GeneralRe: Where to put MFC DLL's Pin
Michael P Butler20-Nov-02 22:13
Michael P Butler20-Nov-02 22:13 
GeneralIID and CLSID from ActiveX controls Pin
Zac Howland20-Nov-02 11:33
Zac Howland20-Nov-02 11:33 
GeneralRe: IID and CLSID from ActiveX controls Pin
dabs20-Nov-02 13:38
dabs20-Nov-02 13:38 
GeneralDifference Between the Heap and The Stack Pin
ursus zeta20-Nov-02 10:55
ursus zeta20-Nov-02 10:55 
GeneralRe: Difference Between the Heap and The Stack Pin
Joaquín M López Muñoz20-Nov-02 11:07
Joaquín M López Muñoz20-Nov-02 11:07 
Well... I guess you've already written some programs in C or C++, right? If so, unless you have used malloc or new, all the variables declared and used in your program live on the stack. They're automatically added and removed on a stack-like manner as the flow of execution progress. For instance:
int a=0; //stack: a
int b=10; //stack: a,b
for(a=0;<b;++a){
  int i=2*a; //stack: a,b,i
}
// stack: a,b
Get the idea? The lifespan of stack variables is automatically taken care of by the compiler.
Sometimes, however, you need to have a variable that lives longer that the context it is declared in. These can be seen as "floating" variables whose birth and death is under control of the programmer, not the compiler --you decide when the variable is created, and when it is destroyed. The space these variables live in is called the heap. In C/C++, heap variables are handled though pointers:
int * a; // pointer to int ("heap-based" int, if you prefer)
...
void f()
{
  a=new int; // a is created, but will survive to termination of f

}
...
delete a; // the program decides now to remove a
This is a very shallow introduction to the concepts, any basic C++ tutorial will explain these things better and in more detail.

Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
GeneralRe: Difference Between the Heap and The Stack Pin
Christian Graus20-Nov-02 13:27
protectorChristian Graus20-Nov-02 13:27 
GeneralRe: Difference Between the Heap and The Stack Pin
dabs20-Nov-02 13:43
dabs20-Nov-02 13:43 
GeneralRe: Difference Between the Heap and The Stack Pin
User 988520-Nov-02 11:10
User 988520-Nov-02 11:10 
GeneralRe: Difference Between the Heap and The Stack Pin
ursus zeta20-Nov-02 11:28
ursus zeta20-Nov-02 11:28 
Generalread a percent from a file Pin
Amit Dey20-Nov-02 10:52
Amit Dey20-Nov-02 10:52 
GeneralRe: read a percent from a file Pin
James R. Twine20-Nov-02 10:59
James R. Twine20-Nov-02 10:59 
GeneralRe: read a percent from a file Pin
Amit Dey20-Nov-02 11:10
Amit Dey20-Nov-02 11:10 
GeneralRe: read a percent from a file Pin
User 988520-Nov-02 11:23
User 988520-Nov-02 11:23 
GeneralRe: read a percent from a file Pin
Amit Dey20-Nov-02 11:30
Amit Dey20-Nov-02 11:30 
GeneralRe: read a percent from a file Pin
James R. Twine20-Nov-02 13:20
James R. Twine20-Nov-02 13:20 
GeneralRe: read a percent from a file Pin
User 988520-Nov-02 13:31
User 988520-Nov-02 13:31 
GeneralRe: read a percent from a file Pin
James R. Twine20-Nov-02 13:59
James R. Twine20-Nov-02 13:59 
GeneralRe: read a percent from a file Pin
User 988521-Nov-02 5:26
User 988521-Nov-02 5:26 
GeneralRe: read a percent from a file Pin
James R. Twine21-Nov-02 9:17
James R. Twine21-Nov-02 9:17 
GeneralRe: read a percent from a file Pin
Amit Dey21-Nov-02 10:34
Amit Dey21-Nov-02 10:34 
GeneralRe: read a percent from a file Pin
User 988521-Nov-02 10:45
User 988521-Nov-02 10:45 
GeneralRe: read a percent from a file Pin
Amit Dey21-Nov-02 12:03
Amit Dey21-Nov-02 12:03 

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.