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
Quiz 1 is open this Thurs-Saturday. It covers weeks 1 and 2.

Schedule

Day 1

  • Pointer review

Day 2

  • Pointers & Objects
  • Aggregation
  • Do Aggregation CPPLab

Day 3

  • Aggregation Wrapup and this

Day 4

  • Quiz 1

  • If you did not do the Source Control & Git material last week, do it now.

    I also encourage you to Do parts 3 & 3 of the Git Tutorial. They will walk you through making your own cs162 repository and add some files to it. Although you do not have to store your code in Github in this course, it is a great way to save backups of your work to the cloud and make it easier to work on multiple different computers.

Online 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 elearn - 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 CPPLab.

This final 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 Elearn. It is time limited (60 minutes) and not collaborative. It covers weeks 1 & 2. 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".

Git - Setup Your Own Repository

In week 2 we introduced source control so that you could access my code. Now is a good time for you to set up your own repository for your code. Doing so (and using it) means you will be able to always access your code wherever you are.

Follow the instructions in parts 2 and 3 of the Git Tutorial to make your own CS162 repository and add some files to it.