C++ Polymorphism and Virtual Member Functions [6]

preview_player
Показать описание
In object-oriented programming, polymorphism enables object reference variables or pointers to reference objects of different types, and to invoke the appropriate member functions based on the type of object being referenced.

Learn how through writing sample classes in this C++ tutorial for beginners written with Visual Studio 2022 C++ .

// Join the new Programming for Everyone Community Forum:

// Learn More //
The Inheritance, Polymorphism,and Virtual Functions play list:

// Consider supporting this channel in multiple ways
Bitcoin: 177wfkQwzXiC8o2whQMVpSyuWUs95krKYB
Рекомендации по теме
Комментарии
Автор

The best explanation I've found on this subject, thank you very much !

orionpluto
Автор

You explained too well. Tomorrow is my exam and I understood the topic completely.
Thank you.

saramomen
Автор

Some time ago, when I used g++, I could type something like this: Square *s = (class Square*)&r; I think this will probably still work and maybe it explains things better.

Johannes-vrvc
Автор

so why did we make all the destrcutors virtual should not that be just for the base class or we did it for readbilty of the code ?

lgt
Автор

Mr.Hank please what is the difference betwen ~square(){}; and virtuel ~square(){}; .Thanks for your explanation

AlexTrouman-oiyp
Автор

class Foo {
void print() const { cout << "Foo!" << endl }
}

What does the "const" mean in this context? What's the difference between including it and not including it?

manedurphy
Автор

Sir, I did not understand something, which is ; Why we put virtual for all destructors meanwhile put virtual for only base class's print function . 

Thank you for considering :)

egetan
Автор

I like you use a geometric example, people like me can visualize the proposed problem, meaning and scope!

massimoazzano
Автор

yea but why the hell would you ever need to use all this shyt, keep it simple and readable.

jesuschrist