Relationship between Virtual Functions, Pure Virtual Functions and Abstract Classes in OOP explained
CodeBeauty CodeBeauty
273K subscribers
151,093 views
0

 Published On Apr 15, 2021

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

🎁 Create Modern Apps, 5x faster, with less code, Download FREE C++Builder Trial: https://bit.ly/CppBuilderFree

☕ If you've found my content helpful and would like to support me, you now have the option to buy me a coffee or a cookie! It's a small gesture of gratitude that means a lot to me and helps me keep creating free educational videos for you. Use the link to make a contribution: https://bit.ly/CodeBeauty_BuyMeACoffee
However, please don't feel obligated to do so. I appreciate every one of you, and I will continue to share valuable content with you regardless of whether you choose to support me in this way. Thank you for being part of the Code Beauty community! ❤️😇

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 📸 -   / truecodebeauty  
Twitter 🐦-   / truecodebeauty  

show more

Share/Embed