Computer Science 1037A/B Lecture Notes - Lecture 2: Memory Address, Memory Management, Memory Leak

31 views5 pages

Document Summary

Each variable is stored at a specific memory location that has a memory address. You can use the address operator & to get the address int num = 5; cout << &num; //prints address in hexadecimal cout << long(&num); //prints address in decimal. The address of a memory location is a pointer, meaning that a pointer is variable that holds an address. Which can be read as intptr can hold the address of an int or the variable that intptr points to has type int. An array name is the starting address of the array. Cout << &vals{0} //should print the same address as vals. An array name can be used as a pointer const. A pointer can be used as an array name. The only difference between arrays names and pointer variables is that you cannot change the address an array name points to because array names are pointer const.

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
Class+
$8 USD/m
Billed $96 USD annually
Class+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
30 Verified Answers

Related Documents