Content deleted Content added
No edit summary |
|||
Line 4:
In [[object-oriented programming]], in languages such as [[C++]], and [[Object Pascal]], a '''virtual function''' or '''virtual method''' is an inheritable and [[Method overriding (programming)|overridable]] [[function (computer science)|function]] or [[method (computer science)|method]] for which [[dynamic dispatch]] is facilitated. This concept is an important part of the (runtime) [[Polymorphism (computer science)|polymorphism]] portion of [[object-oriented programming]] (OOP). In short, a virtual function defines a target function to be executed, but the target might not be known at compile time.
Most programming languages, such as [[JavaScript]], [[PHP]] and [[Python (programming language)|Python]], treat all methods as virtual by default<ref>{{Cite web|title=Polymorphism (The Java™ Tutorials > Learning the Java Language > Interfaces and Inheritance)|url=https://docs.oracle.com/javase/tutorial/java/IandI/polymorphism.html|access-date=2020-07-11|website=docs.oracle.com}}</ref><ref>{{Cite web|title=9. Classes — Python 3.9.2 documentation|url=https://docs.python.org/3/tutorial/classes.html|access-date=2021-02-23|website=docs.python.org}}</ref> and do not provide a modifier to change this behavior. However, some languages provide modifiers to prevent methods from being overridden by derived classes (such as the ''final''
== Purpose ==
|