MENU

Fun & Interesting

Relationship between Virtual Functions, Pure Virtual Functions and Abstract Classes in OOP explained

CodeBeauty 182,775 4 years ago
Video Not Working? Fix It Now

📚 Learn how to solve problems and build projects with these Free E-Books ⬇️ C++ Lambdas e-book - free download here: https://bit.ly/freeCppE-Book Entire Object-Pascal step-by-step guide - free download here: https://bit.ly/FreeObjectPascalEbook 🚀📈💻🔥 My Practical Programming Course: https://www.codebeautyacademy.com/ Experience the power of practical learning, gain career-ready skills, and start building real applications! This is a step-by-step course designed to take you from beginner to expert in no time! 💰 Here is a coupon to save 10% on your first payment (CODEBEAUTY_YT10). Use it quickly, because it will be available for a limited time. In this Object-Oriented Programming course, I'm explaining the relationship and purpose of virtual functions, pure virtual functions, and abstract classes. C++ Virtual functions are functions defined in the base class and redefined in the derived class, whose main purpose is achieving runtime-polymorphism. Virtual functions are defined with the "virtual" keyword in the base class. You can find a detailed explanation and an example in this video, and I'll also show you how the runtime polymorphism achieved by using virtual functions looks like. Pure virtual functions in C++ (abstract function) in C++ is a virtual function for which we don't write implementation in the base class, but we only declare it. In order to declare a pure virtual function, you need to assign 0 in the declaration Abstract class in C++ is a class that has at least one pure virtual function. The classes which inherit the abstract class must provide a definition for the pure virtual functions, otherwise, they would be abstract themselves and you wouldn't be able to instantiate them. The main purpose of an abstract class is to provide an appropriate base class from which other classes can inherit. Contents: 00:00 - Into 01:21 - Virtual Functions 12:21 - Pure Virtual Functions and Abstract Classes 17:28 - Polymorphism example 🎹 Fun fact, on my language accordion is called "Harmonika" like the word harmony. Accordion compositions I like: https://bit.ly/compositionsILike My favorite composition (The Danube Waves): https://bit.ly/TheDanubeWaves Tag me on you Instagram stories: Instagram 📸 - https://www.instagram.com/TrueCodeBeauty Twitter 🐦- https://twitter.com/TrueCodeBeauty

Comment