Polymorphism and Inheritance in C++

0.0(0)
Studied by 0 people
call kaiCall Kai
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
GameKnowt Play
Card Sorting

1/13

flashcard set

Earn XP

Description and Tags

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.

Last updated 8:39 PM on 5/7/26
Name
Mastery
Learn
Test
Matching
Spaced
Call with Kai

No analytics yet

Send a link to your students to track their progress

14 Terms

1
New cards

What are the two main categories of Polymorphism mentioned in the notes?

Compile-Time Polymorphism and Run-Time Polymorphism.

2
New cards

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.

3
New cards

What are three alternative names for the class that is being inherited?

Base class, super class, or parent class.

4
New cards

What are three alternative names for the class that inherits from another class?

Derived class, sub class, or child class.

5
New cards

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.

6
New cards

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.

7
New cards

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.

8
New cards

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.

9
New cards

What is Hierarchical Inheritance?

It is a structure where one common base class is inherited by two or more derived classes.

10
New cards

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.

11
New cards

What is the "diamond problem" in C++ inheritance?

A situation where a derived class DD inherits from two classes (BB and CC) that both inherit from a common base class AA, resulting in DD receiving duplicate copies of AA and causing ambiguity.

12
New cards

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.

13
New cards

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.

14
New cards

In the hybrid inheritance example, which classes serve as the base classes for the class "result"?

The classes "science" and "commerce".