Week 5 - Inheritance, Operators

Learning objectives

Upon finishing this week, you should be able to:

  • Use inheritance to extend classes
  • Identify appropriate uses for abstract classes
  • Describe how virtual functions differ from regular ones and enable polymorphism
  • Create classes that work using standard operators

Suggested pacing

Day 1

Day 2

Day 3

Day 4

Activity Outline

Inheritance

You should have read 19.1-19.4 last week. This week we will finish up Chapter 19.

These optional videos may help:

Overriding functions (Ch 19.5):


Virtual Functions (Ch 19.7):


Object Slicing (Ch 19.8):


Abstract Functions and Classes (Ch 19.9-19.10):


Multiple Inheritance and Interfaces (Ch 19.11):


Composition vs Inheritance (Ch 19.13):

Virtual Call Practice

Virtual functions and object slicing can be tricky concepts. See the Week 5 Module in Canvas for a worksheet that has some practice problems on these topics.

Make sure you are through 19.8 before doing this worksheet.

Inheritance Design Activity

In the Week 5 Module in Canvas you will find a design activity. Tackle it after you have read through 19.12.

Midterm Review

See the week 5 Module in Canvas for a review packet. It is not a sample test per se, but it has examples of the types of questions that might be on the midterm.

The midterm will cover up through inheritance. Like the CS161 exams, the midterm will involve some writing code by hand, but it the code writing is focused on the core ideas, not all the possible syntax details. Unlike the CS161 exams, there will be questions that don't involve writing code, such as explaining ideas or designing a class.

Operator Overloading Basics

Chapter 20 introduces operator overloading. (We are not doing the exercises, just the reading.)

This optional video gives an overview of the chapter: