Difference between revisions of "Intermediate C++ Game Programming Tutorial 18"
From Chilipedia
(→Errata) |
(→Video Timestamp Index) |
||
Line 14: | Line 14: | ||
== Video Timestamp Index == | == Video Timestamp Index == | ||
− | + | [https://www.youtube.com/watch?v=4Vvc1YurUYA Tutorial 18.1] | |
− | * [https://youtu.be/cdOB_gKnJOM Tutorial 18.2] | + | * first comment [https://www.youtube.com/watch?v=4Vvc1YurUYA?t=1m00s 1:00] |
+ | |||
+ | [https://youtu.be/cdOB_gKnJOM Tutorial 18.2] | ||
+ | * WORK-IN-PROGRESS | ||
== Source Code == | == Source Code == |
Revision as of 03:19, 12 October 2019
Another two-parter here, and we got the real stuff now. Virtual functions allow you to unlock the true potential of inheritance in C++. You need to know this shit.
Contents
Topics Covered
Part 1
- How to create a virtual function
- Using the override keyword
- Creating a pure virtual function
- Using a container of pointers to manage a heterogeneous collection of objects
- virtual destructors
Part 2
- Using inheritance and composition together
- Basic idea of a polymorphic state machine and its application to entity behavior
Video Timestamp Index
- first comment 1:00
- WORK-IN-PROGRESS
Source Code
Errata
- Forgot the virtual destructor for
class Weapon
! (this one hurts) - In the children, the function signatures should be:
int CalculateDamage( const Attributes& attr,Dice& d ) const override
- Though not technically an error, it might have been a better decision to make
Weapon::GetName()
andWeapon::GetRank()
(pure) virtual functions (this would reduce the amount of per-instance data to just the vtable ptr)