1/13
A set of flashcards covering polymorphism types, the five main types of inheritance in C++, access control, and the utility of virtual base classes to solve the diamond problem.
Name | Mastery | Learn | Test | Matching | Spaced | Call with Kai |
|---|
No analytics yet
Send a link to your students to track their progress
What are the two main categories of Polymorphism mentioned in the notes?
Compile-Time Polymorphism and Run-Time Polymorphism.
How is inheritance defined in C++?
It is a technique of re-using data members and member functions of an existing class into another class.
What are three alternative names for the class that is being inherited?
Base class, super class, or parent class.
What are three alternative names for the class that inherits from another class?
Derived class, sub class, or child class.
What characterizes Single Inheritance?
It is the simplest type of inheritance where one class is inherited by exactly one other class, involving one base class and one derived class.
What is the specific benefit of using the "protected" access specifier in inheritance?
It allows child classes to access the members of the base class, while "private" would not allow direct access in the derived class.
How is Multilevel Inheritance described?
It occurs when a class inherits a class which in turn inherits another class, creating a chain of inheritance across multiple levels.
What is Multiple Inheritance?
It occurs when a single class is derived from more than one base class, and all base classes are separated by commas in the code.
What is Hierarchical Inheritance?
It is a structure where one common base class is inherited by two or more derived classes.
What is Hybrid Inheritance?
It is a combination that mixes more than one inheritance type in the same program, such as combining multiple inheritance and multilevel inheritance.
What is the "diamond problem" in C++ inheritance?
A situation where a derived class D inherits from two classes (B and C) that both inherit from a common base class A, resulting in D receiving duplicate copies of A and causing ambiguity.
What is the primary purpose of a Virtual Base Class?
To ensure that only one shared copy of a common base class is inherited, regardless of how many inheritance paths exist, thereby removing ambiguity and duplication.
In the multilevel inheritance example, what is the "result" class responsible for?
It handles calculations to compute the total and average percentage based on marks inherited from the "marks" class.
In the hybrid inheritance example, which classes serve as the base classes for the class "result"?
The classes "science" and "commerce".