Download presentation
Presentation is loading. Please wait.
Published byBarnaby Barber Modified over 6 years ago
1
Inheritance But first, a few homework corrections and clarifications
Oh, and a bit of recursion
2
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.
3
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
4
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
5
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
8
Vocab Subclass Superclass Inheritance hierarchy Base class Child class
Parent class Inheritance hierarchy Base class
14
Initializer list
21
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
24
Static Dispatch When a function is called, the specific implementation to be used is determined at compile time
26
or virtual void react() override {
27
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)
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.