Virtual function: Difference between revisions

Content deleted Content added
Line 15:
Virtual functions allow a program to call methods that don't necessarily even exist at the moment the code is compiled.
 
In C++, ''virtual methods'' are declared by prepending the {{Cpp|virtual}} keyword to the function's declaration in the base class. This modifier is inherited by all implementations of that method in derived classes, meaning that they can continue to over-ride each other and be late-bound. And even if methods owned by the base class call the virtual method, they will instead be calling the derived method. '''Overloading''' occurs when two or more methods in one class have the same method name but different parameters. '''Overriding''' means having two methods with the same method name and parameters. Overloading is also referred to as function matching, and overriding as dynamic function mapping.
 
== Example ==