Week 10 - Intro to Pointers and Dynamic Data

Learning Objectives

Upon finishing this learning module, you should be able to:

  • Read code that uses pointers and references
  • Create dynamically allocated storage

Important Upcoming Assessments

Quiz 4 is open this Thurs-Saturday. Covers weeks 8, 9, and 10 (make sure to practice with pointers before taking it).
Schedule an appointment now to take your final. See the discussion board for details.

Day 1

Day 2

  • Start assignment 9B
  • Pointer Basics
  • Read chapter 11.1-11.3
  • Pointer Worksheet

Day 3

Day 4

  • Quiz 4
  • Final review
  • Finish final assignment 9B

Activity Outline

PhotoChop

PhotoChop is a project that puts together a bunch of recent ideas—structs, typedefs, multidimensional arrays, and enums—and lets you have some fun manipulating images. It is a mini-assignment scored as extra credit in the CPPLab category—it can add 5% to your CPPLab score.

Pointers

This week you do not have to write code using pointers (unless you do the challenge for assignment 9). Our goal with the material in Ch11 is just to gain an understanding of what pointers are and how they work. They are a tricky concept that we will learn more about in 162 and rely on heavily for 260... this is the gentle preview of the topic. So by all means, try things out in VSCode, but keep in mind that our goal for now is just to understand them, not master them.

Read chapter 11.1-11.3 about the basics of pointers. This video helps explain what they are:

Do the Pointer worksheet from the Classroom files link. This video explains how to do the problems:

This C++ Code Visualizer can be a handy tool for visualizing what is happening in memory. It shows pointers as arrows to the location they point. That is a good high level mental model, but you should also understand that the pointer is storing something - a memory address.

Dynamic Memory

Watch this video about dynamic memory:

Read 11.9.

Final Review

The final is next week! Check in Elearn in the Files area for the Practice Final.

Practice doing it with pen and paper - you will not be able to use VSCode for the final!