Hi everybody,
I have two questions:
1) About memory space in C++
2) About global and static variable
As what I read somewhere that after compilation process which translate C++ code into machine language, your application is given a certain amount of memory to use, that memory space is divided into 4 segments as follow
a. Code segment, where all application code is stored
b. Data segment, where global data is stored
c. Stack segment, where local variables are stored
d. Heap segment, where dynamic memory is used
First question, is my statement correct?
Anyway, thanks a lot for your concern and help
I have two questions:
1) About memory space in C++
2) About global and static variable
As what I read somewhere that after compilation process which translate C++ code into machine language, your application is given a certain amount of memory to use, that memory space is divided into 4 segments as follow
a. Code segment, where all application code is stored
b. Data segment, where global data is stored
c. Stack segment, where local variables are stored
d. Heap segment, where dynamic memory is used
First question, is my statement correct?
If correct, the second question:
Are all global and static variables initialized when program start and exist until the program is terminated? Where are these types of variable located? Is it data segment?
If the first question is wrong, my second question
How is memory space allocated for an application? Where are all types of variable located?
Anyway, thanks a lot for your concern and help
Comment