1/42
Looks like no tags are added yet.
Name | Mastery | Learn | Test | Matching | Spaced | Call with Kai |
|---|
No analytics yet
Send a link to your students to track their progress
Inheritance
A way to create a new class from an existing class. The new class is a specialized version of the existing class.
Base Class
The class being inherited from. Also called the parent class.
Derived Class
The class that inherits from another class. Also called the child class.
Parent Class
Another name for base class.
Child Class
Another name for derived class.
Is-a Relationship
The relationship represented by inheritance. Example: Dog is an Animal.
Creating a Derived Class
Using syntax like class Dog : public Animal. This means Dog inherits from Animal.
Public Inheritance
Inheritance where public base members stay public and protected base members stay protected in the derived class.
Protected Inheritance
Inheritance where public and protected base members become protected in the derived class.
Private Inheritance
Inheritance where public and protected base members become private in the derived class.
Inherited Member
A member from the base class that becomes part of the derived class object.
Base Class Private Member
A private base member is inherited but cannot be directly accessed by the derived class.
Protected Member
A member accessible by the class itself and derived classes, but not outside code.
Constructor Order in Inheritance
When a derived object is created, the base class constructor runs first, then the derived class constructor.
Destructor Order in Inheritance
When a derived object is destroyed, the derived class destructor runs first, then the base class destructor.
Passing Arguments to Base Constructor
A derived constructor can call a base constructor using an initialization list. Example: Square(int s) : Rectangle(s, s).
Constructor Initialization List
The section after a constructor heading that initializes base classes or members. Example: : Base(x).
Constructor Inheritance
Letting a derived class inherit base class constructors using using Base::Base;.
Redefining
A derived class creates a function with the same name and same parameter list as a non-virtual function in the base class.
Overriding
A derived class replaces a virtual function from the base class with its own version.
Redefining vs. Overriding
Redefining is non-virtual and uses static binding. Overriding requires a virtual base function and uses dynamic binding.
Function Overloading
Same function name but different parameter lists. This is different from redefining.
Static Binding
C++ decides which function to call at compile time. Happens with non-virtual functions.
Dynamic Binding
C++ decides which function to call at runtime. Happens with virtual functions.
Virtual Function
A base class function marked with virtual, allowing derived versions to be called through base references or pointers.
Polymorphism
The ability for the same function call to behave differently depending on the actual object type.
Runtime Polymorphism
Polymorphism that happens while the program is running through virtual functions.
Base Class Pointer
A pointer of the base class type that can point to a derived class object.
Base Class Reference
A reference of the base class type that can refer to a derived class object.
Object Slicing
When a derived object is copied into a base object by value, causing the derived part to be lost.
override Keyword
A keyword that tells the compiler a derived function is intended to override a virtual base function.
final Keyword
A keyword that prevents a virtual function from being overridden further.
Virtual Destructor
A destructor marked virtual so deleting a derived object through a base pointer calls the correct destructors.
Abstract Class
A class that cannot be used to create objects because it contains at least one pure virtual function.
Pure Virtual Function
A virtual function with = 0. Example: virtual void show() = 0;.
Concrete Class
A class that can be used to create objects. It has no unimplemented pure virtual functions.
Interface-like Class
A class made mostly or entirely of pure virtual functions, used to define required behavior for derived classes.
Creating Abstract Classes
A class becomes abstract when it has at least one pure virtual function.
Implementing Pure Virtual Functions
A derived class must define inherited pure virtual functions before objects of that derived class can be created.
Multiple Inheritance
A derived class inherits from more than one base class.
Name Conflict in Multiple Inheritance
A problem where two base classes have members with the same name. Use scope resolution to clarify.
Scope Resolution in Inheritance
Using BaseClass::functionName() to specify which class version of a function to call.
Instance of Concept
In C++, an object is an instance of a class. C++ does not have a Java-style instanceof keyword, but base pointers/references can point to derived objects through inheritance.