H Study Guide - Final Guide: Null Pointer, Local Variable

11 views1 pages

Document Summary

To be successful as a c++ programmer, it"s essential to have a good understanding of how dynamic memory works. In a c++ program, memory is divided into two parts: The stack: all of your local variables take up memory from the stack. The heap: unused program memory that can be used when the program runs to dynamically allocate the memory. Many times, you are not aware in advance how much memory you will need to store particular information in a defined variable and the size of required memory can be determined at run time. You can allocate memory at run time within the heap for the variable of a given type using the new operator, which returns the address of the space allocated. This allocates the memory size necessary for storing an integer on the heap, and returns that address. The allocated address can be stored in a pointer, which can then be dereferenced to access the variable.

Get access

Grade+20% off
$8 USD/m$10 USD/m
Billed $96 USD annually
Grade+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
40 Verified Answers

Related Documents