JOIN ME
—————
YouTube 🎬 [ Ссылка ]
Patreon 🚀 [ Ссылка ]
COMPLETE PLAYLIST
————————————
C++ Tutorial For Beginners: [ Ссылка ]
STL (Standard Template Library): [ Ссылка ]
ThreadIng In C++: [ Ссылка ]
Data Structures: [ Ссылка ]
Algorithms: [ Ссылка ]
Design Patterns: [ Ссылка ]
Smart Pointers: [ Ссылка ]
C++14: [ Ссылка ]
C++17: [ Ссылка ]
C++ All Type Casts: [ Ссылка ]
INTERVIEW PLAYLIST
————————————
C++ Interview Q&A: [ Ссылка ]
C++ Interview Q&A For Experienced: [ Ссылка ]
Linked List Interview Questions: [ Ссылка ]
BST Interview Questions: [ Ссылка ]
Array Interview Questions: [ Ссылка ]
String Interview Questions: [ Ссылка ]
Bit Manipulation Questions: [ Ссылка ]
Binary Tree Interview Question: [ Ссылка ]
Sorting Algorithms: [ Ссылка ]
C++ MCQ: [ Ссылка ]
C MCQ: [ Ссылка ]
C Interview Questions: [ Ссылка ]
QUICK SHORT VIDEOS
————————————-
C++ Short : [ Ссылка ]
C Short : [ Ссылка ]-
In this video we will learn about what is virtual function and how to use it in C++.
NOTES:
1. WHY to use virtual function?
a. To achieve dynamic polymorphism. Which is the ability to call Derived class function using Base class pointer or reference.
2. HOW to use virtual function?
a. By declaring function as virtual in Base class and overriding that function in Derived class.
(Function signature should be same in Base and Dervied class)
b. Declaring a function as virtual in Base class is enough, Derived class function need not to be declared virtual.
c. Virtual functions should be accessed using pointer(*) or reference(&) of Base class type to achieve run time polymorphism.
ADITIONAL NOTES:
1. Virtual functions cannot be static and also cannot be a friend function of another class.
2. A class can have virtual destructor but can't have virtual constructor.
3. There are two types of virtual functions in C++.
a. Virtual Function
b. Pure Virtual Function
#cpp #virtualfunction #programming #interviewquestions #softwareengineering #computerscience
Ещё видео!