Lec09 (Topic 5 Inheritance)
Lec09 (Topic 5 Inheritance)
Inheritance (Part 1)
The “is-a” Relationship
• By nature we commonly group objects that share attributes
and/or behaviors into classes/categories.
Subclass C
Virtual Inheritance
• Multiple inheritance may introduce diamond inheritance problem,
which arises when two classes B1 and B2 inherit from A, and class C
inherits from both B1 and B2.
B1 B2
C
Virtual Inheritance
Problem
A
class A {};
class B1: public A {};
class B2: public A {};
class C: public B1, public B2 B1 B2
{};