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

Deadlines This Week:

  • NEXT WEEK - Final : Online Students should set up appointment time NOW. See discussion board post for deadline/info.
  • Saturday 11:59PM (Opens Thursday)- Quiz 4 - covers weeks 8-10.
    This includes the material on pointers from this week (Ch 11) - you need to get through that material before you take the quiz.
  • Friday 11:59PM - Photochop mini-assignment - turn in your functions in elearn.
    • Build at least two new image creation/modification functions for PhotoChop. You must build make functions from two different categories (Create Image/Basic Filter/Complex Filter/Size Modifying/Multiple Image).
  • Sunday 11:59PM - Assignment 9. No late work will be accepted for assignment 9.

Classroom Schedule:

Monday
  • Pointer Basics
  • Read chapter 11.1-11.3
  • Pointer Worksheet
Tuesday
  • Dynamic Memory
  • Read chapter 11.9
Wednesday
  • Final review
Friday
  • Take quiz 4 online
  • Come in for quiz/final practice or assignment questions

Activity Outline:

Pointers


Note - 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 proficiently use 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. There is an example problem and key is available in that folder as well.
  • 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.
  • Watch this video about dynamic memory:
  • Read 11.9

Extra Info:

C++ Notes

These items linked to on this page have nice conscise pointer information
C++ Notes focus on ones called:
  • Addresses, pointers, references
  • Pointers
  • The NULL pointer
  • Dynamic Allocation of Arrays

Learncpp.com

This online tutorial covers some of the same ground as the Liang readings:
LearnCpp.com 6.7-6.9 for Pointers and dynamic allocation

Classroom slides/examples:

Directory of files from the week
Right click files and save to your computer

Notes:

  1. Congrats - you are almost there!
  2. Start studying for the final now. Go back to earlier chapters (especially ones you had problems with), do questions from the end of each chapter and check yourself.