MENU

Fun & Interesting

Virtual Function In C++

CppNuts 38,028 4 years ago
Video Not Working? Fix It Now

JOIN ME ————— YouTube 🎬 https://www.youtube.com/channel/UCs6sf4iRhhE875T1QjG3wPQ/join Patreon 🚀 https://www.patreon.com/cppnuts COMPLETE PLAYLIST ———————————— C++ Tutorial For Beginners: https://www.youtube.com/watch?v=3IynvwjrV-U&list=PLk6CEY9XxSIAQ2vE_Jb4Dbmum7UfQrXgt STL (Standard Template Library): https://www.youtube.com/watch?v=LyGlTmaWEPs&list=PLk6CEY9XxSIA-xo3HRYC3M0Aitzdut7AA ThreadIng In C++: https://www.youtube.com/watch?v=TPVH_coGAQs&list=PLk6CEY9XxSIAeK-EAh3hB4fgNvYkYmghp Data Structures: https://www.youtube.com/watch?v=7tLVMUKLu2s&list=PLk6CEY9XxSIBG2Gv6-d1WE3Uxqx94o5B2 Algorithms: https://www.youtube.com/watch?v=4FxAK1tjLto&list=PLk6CEY9XxSICTSMyFM3GxRIwiZ7uqlJ9H Design Patterns: https://www.youtube.com/watch?v=XyNWEWUSa5E&list=PLk6CEY9XxSIDZhQURp6d8Sgp-A0yKKDKV Smart Pointers: https://www.youtube.com/watch?v=wUzn0HljjRE&list=PLk6CEY9XxSIAI2K-sxrKzzSyT6UZR5ObP C++14: https://www.youtube.com/watch?v=1EAL_RRCKhY&list=PLk6CEY9XxSIAloDTEauOy_ss9fEqSP4JR C++17: https://www.youtube.com/watch?v=aH7tYWjndgk&list=PLk6CEY9XxSIAEzHd_hTO-PRD6L8XfIUzu C++ All Type Casts: https://www.youtube.com/watch?v=HlNVgmvX1EI&list=PLk6CEY9XxSIC6I_HCjMTGf8eV2Ty0a19E INTERVIEW PLAYLIST ———————————— C++ Interview Q&A: https://www.youtube.com/watch?v=QSuBwGmFQqA&list=PLk6CEY9XxSIDy8qVHZV-Nf-r9f2BkRZ6p C++ Interview Q&A For Experienced: https://www.youtube.com/watch?v=p2z7SJ5MWV8&list=PLk6CEY9XxSIDVpUt0yxC0b3IqDk63U7Bg Linked List Interview Questions: https://www.youtube.com/watch?v=M5tQ4fJMsr0&list=PLk6CEY9XxSICJ0XSI7fbQFiEpDHISJxqT BST Interview Questions: https://www.youtube.com/watch?v=RXeI7k9rhgE&list=PLk6CEY9XxSIAOYLZRHT20Zp3sPIbMzUNk Array Interview Questions: https://www.youtube.com/watch?v=Z2TulQg5t30&list=PLk6CEY9XxSIDApw_RB8cowBQmzrznmpTA String Interview Questions: https://www.youtube.com/watch?v=PnhL-c36JzM&list=PLk6CEY9XxSICY0vpYUdMlv-1Gk5CzuyQQ Bit Manipulation Questions: https://www.youtube.com/watch?v=9CWVhu38a-Q&list=PLk6CEY9XxSIC5KqCCuaIVcuuFaXfAVWy8 Binary Tree Interview Question: https://www.youtube.com/watch?v=att1zpryvCw&list=PLk6CEY9XxSIAA3F1TVDoBTE0Lx-LZ5Ym6 Sorting Algorithms: https://www.youtube.com/watch?v=Vv-gs437i2g&list=PLk6CEY9XxSICqQ9wicEpRh3jYNTtSHVOy C++ MCQ: https://www.youtube.com/watch?v=RJqS2JwlM6E&list=PLk6CEY9XxSIAr1ig2XzKJ1XS23Pn7SVnK C MCQ: https://www.youtube.com/watch?v=yRzEGZ-QouU&list=PLk6CEY9XxSIBs60KjvhQMtjl1UjVcJC2E C Interview Questions: https://www.youtube.com/watch?v=RQZ9DE4nUR4&list=PLk6CEY9XxSIB9jwcI0SP_FbamuqSWxvse QUICK SHORT VIDEOS ————————————- C++ Short : https://www.youtube.com/playlist?list=PLk6CEY9XxSIChg28m9UnVkPpfJobvlheb C Short : https://www.youtube.com/playlist?list=PLk6CEY9XxSIAPNa21YdP5jcwaRgEfXF4- 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

Comment