filmov
tv
C++ OOP 8: POLYMORPHISM
Показать описание
In this 8th lesson of object-oriented programming in C++, you will learn about polymorphism. Polymorphism means many forms. You can have same method name inside base class and derived class. With which class you declare object from that class will method be called. You can also have pointer of base class which stores address of object of derived class. In that case the method from base class will be called. If you want the method from derived class to be called, then you should make that method inside base class virtual. You should also make destructor inside base class virtual to allow destructor from derived class to be called which will destroy complete object. You can also cast pointers. It is done with dynamic cast.
TIMESTAMPS:
0:00 Virtual functions
4:34 Dynamic cast
8:21 Outro
TIMESTAMPS:
0:00 Virtual functions
4:34 Dynamic cast
8:21 Outro