Inheritance But first, a few homework corrections and clarifications Oh, and a bit of recursion
Corrections Classes are cancelled next Wednesday for LeAD day and the Mass of the Holy Spirit Since there won’t be any class, there’s no point having the assignment due by the start of class The assignment is now due September 13 at 11:59pm.
FAQs Do I need to change functions like addFront and popFront? Those functions have no loops, so no changes are needed Am I guaranteed to get full credit if main.cpp runs correctly? NO. There are some possible bugs that main.cpp won’t detect. Consider what happens when the list is very small… Should I use global variables to get information from one function to another? Short answer: no Long answer: noooooooooooooooooooooo
Recursion int itemCountUntilNegative(int arr[]) Let's say we wanted to write a recursive function that takes in an array and returns the number of elements in the array until a negative element occurs
Inheritance Inheritance allows you to take an existing class and add onto what is done in it Let's start with an example, and then talk about what's going on
Vocab Subclass Superclass Inheritance hierarchy Base class Child class Parent class Inheritance hierarchy Base class
Initializer list
Access modifiers public: protected: private: Everyone can read and write these variables, and call these functions protected: This class and all subclasses can read and write variables, and call functions private: Only this class, not subclasses, can read/write variables, call functions
Static Dispatch When a function is called, the specific implementation to be used is determined at compile time
or virtual void react() override {
Dynamic dispatch The specific function implementation to use for a function call is resolved at run time Polymorphism: "In programming languages and type theory, polymorphism (from Greek πολύς, polys, "many, much" and μορφή, morphē, "form, shape") is the provision of a single interface to entities of different types.[1] A polymorphic type is one whose operations can also be applied to values of some other type, or types.[2]" (Thank you, Wikipedia)