Pure Virtual Function In C++

Описание к видео Pure Virtual Function In C++

JOIN ME
—————
YouTube 🎬    / @cppnuts  
Patreon 🚀   / cppnuts  

COMPLETE PLAYLIST
————————————
C++ Tutorial For Beginners:    • Introduction To C++  
STL (Standard Template Library):    • STL In C++  
ThreadIng In C++:    • Multithreading In C++  
Data Structures:    • Data Structure  
Algorithms:    • Binary Search  
Design Patterns:    • Factory Design Pattern in C++  
Smart Pointers:    • Smart Pointer In C++  
C++14:    • Digit Separator In C++  
C++17:    • std string_view in C++17 | Fastest St...  
C++ All Type Casts:    • static_cast In C++  


INTERVIEW PLAYLIST
————————————
C++ Interview Q&A:    • Structural Padding & Packing In C & C++  
C++ Interview Q&A For Experienced:    • How delete[] Knows How Much  To Deall...  
Linked List Interview Questions:    • Find Kth Node From Back In Singly Lin...  
BST Interview Questions:    • Search Element In Binary Search Tree ...  
Array Interview Questions:    • Reverse An Array  
String Interview Questions:    • Check String Is Palindrome Or Not  
Bit Manipulation Questions:    • Find Set Bit In Integer Number  
Binary Tree Interview Question:    • Invert Binary Tree  
Sorting Algorithms:    • Bubble Sort  
C++ MCQ:    • Видео  
C MCQ:    • What printf returns after printing? |...  
C Interview Questions:    • Designated Initialization In C  

QUICK SHORT VIDEOS
————————————-
C++ Short :    • C++ Short Videos  
C Short :    • Shorts C Programming MCQ  

Pure Virtual Function

SYNTAX: virtual returntype functionname(parameters...) = 0;

NOTES:
0. If some class can have only signature of function but not the body then we use pure virtual functions.
1. Sometimes in Base class we know the function name but not the definition of the function, so we want Derived classes to provide the definition of the function.
2. We can actually give body of pure virtual function.
3. If you have pure virtual function in your class, it means that class is an Abstract class and you can't create an object of that class. (But pointers and Reference can be created)

USE CASE:
1. Used to create abstract classes, which helps in creating interfaces (APIs)

#cpp #virtualfunction #programming #coding #softwareengineering

Комментарии

Информация по комментариям в разработке