When you have an inheritance situation like this, under normal circumstances, because D is inheriting from both B and C and because A is at the top of the diamond shape, D will get 2 copies of the members and variables within A. This can be avoided by applying the virtual keyword:
virtual ~Animal() = default;
virtual void Eat() {}
};
// Two classes virtually inheriting Animal:
struct Mammal: virtual Animal {
virtual void Breathe() {}
};
struct WingedAnimal: virtual Animal {
virtual void Flap() {}
};
// A bat is still a winged mammal
struct Bat: Mammal, WingedAnimal {};
C++ For C# Developers: Part 14 - Inheritance - JacksonDunstan.com