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
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










