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
Schedule
Day 1
- Photochop
- Photochop mini assignment
Day 2
- Pointer Basics
- Read chapter 11.1-11.3
- Pointer Worksheet
Day 3
- Dynamic Memory
- Read chapter 11.9
Day 4
- Quiz 4
- Final review
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.
See the Week09 samples for the starter code. This video explains it:
PhotoChop mini-assignment (scored as a CPPLab): Make (at least) two new image functions - you should make one each from two different categories (Create New Image, Basic Image, Complex Image Modification, Moving Pixels, Combining Pixels, and Multiple Files).
You should turn this into elearn by submitting JUST your main.cpp file. It is scored as a CPPLab, not a major assignment.
Pointers
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
Final prep
The final exam will be a similar format to the midterm. There is a practice final available in elearn.