What is a virtual function, and its use?
Anonymous
A virtual function is a type of function that can be overridden in an inherited class. One can have a pure virtual function, making the class an interface; all the inherited classes also become an interface if they don't implement this pure virtual function, i.e. they cannot be instantiated. It is a good practice to mark the overridden function with the override keyword to make it clear that this function overrides the virtual function from the base class. Virtual functions help us achieve runtime polymorphism, which allows the program to decide, at runtime, which version of the function to invoke based on the actual type of the object being pointed to, rather than the type of the pointer or reference
Check out your Company Bowl for anonymous work chats.