Week 3 - Pointers & Objects, Aggregation
Learning objectives
Upon finishing this week, you should be able to:
- Write code that uses pointers and references
- Use aggregation to build objects from other objects
Suggested pacing
Day 1
- Holiday
Day 2
- Pointer review
Day 3
- Pointers & Objects
- Aggregation
- CPP Lab Aggregation
Day 4
- Aggregation Wrapup and
this
- Quiz 1
Activity Outline
Pointers Review
Review 11.1-11.2 which should be a review from 161. Rewatch this video if you don't feel confident about pointers and memory addresses:
Then read 11.3-11.4 and 11.6-11.7. This material expands on the basics from 161.
Watch these videos (related code is in the Github repository):
Do the Pointer Worksheet from the Files area in Canvas - it is similar to the one from CS161 but has more complex problems. Start by reading the PointerWSExample file - it shows you how you should record the effects of lines of code. Use the PointerWSKey to check your work.
Pointers and Objects
Read 11.10.
Watch this video:
Aggregation
Read learncpp.com Ch 22.3 for the ideas behind aggregation—don't worry too much about the Teacher/Department sample they use; though the idea makes sense, their example is too stripped down to be informative. (Book Ch10.8 also talks about it, but in a very limited way).
Watch these videos:
Do the Aggregation CPP Lab
This next video looks at using aggregation to model relationships between people and to navigate those relationships. It should give you an idea about how to attack parts of this week's assignment.
The video shows how to use the debugger to view an array that has been passed into a function (3:42 mark). You will need to use this trick a lot in future weeks.
Any time you have a variable - call it myarray
that you are sure is an array,
but the debugger just shows a single item, you should add a Watch to see the
array. For the watch, use this syntax:
myarray, 10
Where myarray
is the name of the variable that you are trying to see an array
through, and 10 is the number of items you want to be shown.
Using this
Read 11.11.
Watch this video on a couple tips about using this
:
Quiz
Quiz 1 will be open Thursday–Saturday in Canvas. It is time limited (60 minutes) and must be done on your own, without collaboration. Make sure you block out an hour of uninterrupted time before you start the quiz—you can not pause the timer once you start.
The topics include weeks 1 and 2 (Ch 9/10 + Unit Testing & Test Driven Development). You are not responsible for 10.1/10.2 (string stuff) on the quiz.
To practice, go to the Resource Links and look for "Practice Quiz Questions".