Lec21 - Lecture 21: Introduction to Pointers PIC 10A Todd...

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
1 Lecture 21: Introduction to Pointers PIC 10A Todd Wittman Why Are You Making Us Do This??? s This week we’re covering Ch. 7 on pointers. s Pointers get into the nitty-gritty of how variables are stored in memory. s Applications include memory management, dynamic arrays, and advanced data structures like linked lists. s But this is a little beyond what we need in 10A. s So why are we learning about pointers? s For those of you going on to 10B, it’s worthwhile to get some exposure to pointers. s For those of you not taking 10B, you need to learn pointers because it will be on the final. So there.
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
2 The Memory Address s Recall that a reference parameter sends the address (also called reference ) of the variable x with an . void my_fun (int &x, int y) { ... s The value parameter y creates a local copy of the variable. s When the program is running, all variables are kept in the memory heap . s Each variable is stored with a hexadecimal address (, e.g. 0012FED4), so we know where to find it in the heap. int x = 42; cout << x; //Prints out value of x: 42 cout << &x; //Prints out address of x: 0012FED4 s There’s a difference between the value and the address of a variable! Pointers
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 04/27/2010 for the course PIC 157-050-21 taught by Professor Wittman during the Fall '10 term at UCLA.

Page1 / 7

Lec21 - Lecture 21: Introduction to Pointers PIC 10A Todd...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online