Classes part 24 - Multiple Inheritance Revisited (Virtual inheritance) | Modern Cpp Series Ep. 61

preview_player
Показать описание

►Lesson Description: In this lesson we revisit multiple inheritance, an often frowned upon technique. That said, there are legitimate use cases, and you will see multiple inheritance used in large codebases. One technique to manage the shared (or duplicate) variables in inheritance hierarchies, is to use 'virtual inheritance'. Virtual inheritance 'merges' shared variables that are the grandparent of the current derived class. This essentially creates a 'diamond' inheritance pattern in the hierarchy. As always use caution, but in some scenarios this can be a useful tool to deriving new objects.

►Please like and subscribe to help the channel!
Рекомендации по теме
Комментарии
Автор

This is literally the ONLY correct AND full explanation of the diamond problem on YouTube

hristovalev
Автор

brilliant as always = thank you so much❤

sallaklamhayyen
Автор

Superb Explanation. Thanks a lot Mike for visual investigation about virtual keyword behavior.

bullikoti
Автор

Excellent. Very wonderfully explained as always. Thank you.

dhanushs
Автор

For the nth time, can’t get enough
Thanks Prof MS

joebosah
Автор

You beat everyone on youtube on this topic!!!💘🙏

shaileshdubey
Автор

If I have a virtual base class, say Actor, that has two float vars---position_x and position_y---will the value of those vars be identical between all derived classes? For example, we have a Player class and an Enemy class, and both derive from the Actor class . . . are their position variables going to be identical and every actor just ends up on top of each other, or can they be unique to each instance of Actor? I guess a better way to ask it would be, are virtual class members static or not? I hope that makes sense lol.

LinkinVerbz
Автор

Thanks for the fantastic video series Mike!

chomandengnya