What is a Virtual Function?

Virtual Function is a member function declared using the Virtual keyword in the Base class having same function name in the Derived Class as well. Virtual function implements the concept of Polymorphism in C++ programming language. To implement Run time polymorphism a pointer of base class is used. Compiler chooses at the run time the function to call by looking at the contents of Base class pointer rather than the type of pointer means that if it contains the address of the Base class object it will call member function of base class otherwise if it contains the address of Derived class object then it will call function of Derived class.

More Questions

Leave a Reply

Word Verfication * Time limit is exhausted. Please reload CAPTCHA.