Lesson 2
I don't like templates. Especially some of the long error messages.
If I have to type
template <typename T>
one more time, I swear I'll ram something.There is another way to avoid copying and pasting code. A way that was in C++ long before templates, and there are still times when it's the right choice.
MORE to learn?! I'm excited!
This lesson will address aspects of following goals from Group 10:
- Goal 10B: Inheritance and Subtype Polymorphism:
- Recognize code that creates derived classes from a base class, methods declared
virtual
and code that creates an abstract base class. - Apply the rule for dynamic dispatch to determine which function will be called.
Outline
- Before You Start
- Polymorphism
- Example: The CS 70 Petting Zoo
- Using Our Petting Zoo
- Dynamic Dispatch
- Polymorphic Storage
- Pure Virtual Member Functions
- A More Realistic Example
- Key Points
- Before You Go…
To receive credit: complete all pages above, then this page will be complete as well (and get a green check emoji at the bottom right of the page).
(When logged in, completion status appears here.)