C++ Tutorial 21: Polymorphism @WhatsACreel
C++ Tutorial 21: Polymorphism  @WhatsACreel
Uploaded March 2014 | Updated September 2026, 2 weeks ago
This tute's on polymorphism.

The point to polymorphism is pretty hard to describe, it's very useful for programming with GUI's or making OO based games. Basically, we want to write code that does different but appropriate things based on different data types. It's very closely tied to inheritance. We want to write functions which treat derived/child objects appropriately, instead of treating everything like the parent class. We don't want to use some gigantic collection of "if" statements to get our objects to call appropriate functions. So we inherit from a parent class but override the parent's functions, the child classes still use the same function names as the parent class, but they specify their own code!

I've also briefly described interfaces, abstract classes and purely virtual methods.

I don't know if I mentioned in this tute, but you can create a new Child object with a pointer to an abstract class. This is fine because you're not making an instance of the abstract class, rather, you're making an instance of the Child class, and pointing to it with the parent pointer:
AbstractParent* p = new Child();

FaceBook:
facebook.com/pages/WhatsaCreel/167732956665435
C++ Tutorial 21: PolymorphismSet Associative Caches 2: AMD vs Intel Cache CommentaryAgner Fogs VCL 2: Performance Programming using Vector Class LibraryWhy is Radix Sort so Fast? Part 2 Radix SortC++ 11 Lambda FunctionsNVIDIA CUDA Tutorial 8: Intro to Shared MemoryC++ Tutorial 15: Structures Explained (Game Programming)x64 Assembly Tutorial 49: SSE Arithmetic and Dynamic MemoryLinux x64 Assembly Tutorial 5: Boolean Bitwise InstructionsModern x64 Assembly 11: Division with the DIV and IDIV InstructionsModern x64 Assembly 8: Shift, Rotate and Bit Manipulation InstructionsC++ Tutorial 18: Function Overloading
Creel |

C++ Tutorial 21: Polymorphism

SHARE TO X SHARE TO REDDIT SHARE TO FACEBOOK WALLPAPER