Week 10 - Intro to Pointers and Dynamic Data

Learning Objectives

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

  • Use enums and typedefs to improve code readability and safety
  • Read code that uses pointers and references

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).
The final assignment will not be accepted late to allow for adequate grading time during finals week. Make sure to turn in what you have done by the due date.

The final is next week is an in-person, pen and paper exam.

I will have two blocks of time available next week where you can drop in and take the exam. See discussion board for details.

If you can't make one of those times, you can book an appointment in the testing center, or the math hub, or get my approval to have it proctored somewhere else. You will NOT be able to make an appointment at one of these location and take the test in the same day. Book your appointment NOW if you intend to use one.

Schedule

Day 1

Day 2

Day 3

Day 4

  • Quiz 4
  • Final review

Activity Outline

Enums

Read about enumerations in Appendix G of the textbook. This video covers the key ideas:

Do Enums CPP Lab

Typedef & Namepsaces

These are topics you should know about and recognize, but will not be using frequently. Don't worry about mastery, just make sure you understand these tools when you see them.

This video covers the core ideas:

Our book doesn't have great coverage, but you can use Leancpp.com as a reference to skim for more info: Typedef page and Namespaces page

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 QtCreator, 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.

You won't have to program with dynamic memory here in 161 unless you want to be able to read in a large number of records for your final assignment.

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 QTCreator for the midterm!