filmov
tv
Virtual Functions & Abstract Classes in C++ | C++ Programming Tutorials

Показать описание
Support Simple Snippets by Donations -
--------------------------------------------------------------------------------------------- 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.
Simple Snippets Official Website -
Simple Snippets on Facebook-
Simple Snippets on Instagram-
Simple Snippets Google Plus Page-
Simple Snippets email ID-
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
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
--------------------------------------------------------------------------------------------- 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.
Simple Snippets Official Website -
Simple Snippets on Facebook-
Simple Snippets on Instagram-
Simple Snippets Google Plus Page-
Simple Snippets email ID-
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
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
Комментарии