Saved Bookmarks
| 1. |
When a C++ program is executed, the primary memory allocated for it is organized in a particular manner to deal with runtime memory allocation, function calls, variables, etc. Show a diagrammatic representation of it with brief explanation. |
||||||||||
|
Answer» After compilation of C++ creates four distinct regions of memory used for distinct functions:
The first area (1) is used for storing the compiled code of the program. The second area (2) is used for storing global variables of the program. It remains in memory till the program ends. The third region (3) known as the stack is used for holding the return addresses of function calls, arguments passed to the function, etc. The last region heap is used for dynamic allocation. |
|||||||||||