Virtual Functions & Abstract Classes in C++ | C++ Programming Tutorials
Simple Snippets Simple Snippets
241K subscribers
167,763 views
0

 Published On Jan 20, 2018

Support Simple Snippets by Donations -
Google Pay UPI ID - tanmaysakpal11@okicici
PayPal - paypal.me/tanmaysakpal11
--------------------------------------------------------------------------------------------- In this video tutorial we will study and understand the concept of Virtual Functions and Abstract Classes and we will also see 2 practical examples of Virtual Functions.

Virtual Function in C++ - A virtual function is a member function which is declared within base class and is re-defined (Overridden) by derived class.
When you refer to a derived class object using a pointer or a reference to the base class, you can call a virtual function for that object and execute the derived class’s version of the function.
1) Virtual functions ensure that the correct function is called for an 2) object, regardless of the type of reference (or pointer) used for function call.
3) They are mainly used to achieve Runtime polymorphism
4) Functions are declared with a virtual keyword in base class.
5) The resolving of function call is done at Run-time.

Pure Virtual Functions & Abstract Class in C++ - Sometimes implementation of all function cannot be provided in a base class because we don’t know the implementation. Such a class is called abstract class.
A pure virtual function (or abstract function) in C++ is a virtual function for which we don’t have implementation, we only declare it. A pure virtual function is declared by assigning 0 in declaration. 
Some important facts –
1) A class is abstract if it has at least one pure virtual function.
2) We can have pointers and references of abstract class type.
3) If we do not override the pure virtual function in derived class, then derived class also becomes abstract class.
4) Abstract classes cannot be instantiated.

Download Dev C++ IDE : https://sourceforge.net/projects/orwe...
Download C++ Android App : https://play.google.com/store/apps/de...

Simple Snippets Official Website -
https://simplesnippets.tech/
Simple Snippets on Facebook-
  / simplesnippets  
Simple Snippets on Instagram-
  / simplesnipp.  .
Simple Snippets Google Plus Page-
https://plus.google.com/+SimpleSnippets
Simple Snippets email ID-
[email protected]

For Classroom Coaching in Mumbai for Programming & other IT/CS Subjects Checkout UpSkill Infotech - https://upskill.tech/

UpSkill is an Ed-Tech Company / Coaching Centre for Information Technology / Computer Science oriented courses and offer coacing for various Degree courses like BSc.IT, BSc.CS, BCA, MSc.IT, MSc.CS, MCA etc.

Contact via email /call / FB /Whatsapp for more info
email - [email protected]

We also Provide Certification courses like -
Android Development
Web Development
Java Developer Course
.NET Developer Course
Check us out on Social media platforms like Facebook, Instagram, Google etc
Facebook page -   / upskillinfotech  
Insta page -   / upskill_infotech  
Google Maps - https://goo.gl/maps/vjNtZazLzW82

show more

Share/Embed