Method overriding

overrideoverriddenoverridingoverrideshidingHiding (programming)overridableoverridable methodredefinition
Method overriding, in object-oriented programming, is a language feature that allows a subclass or child class to provide a specific implementation of a method that is already provided by one of its superclasses or parent classes.wikipedia
51 Related Articles

Method (computer programming)

methodsmethodabstract method
Method overriding, in object-oriented programming, is a language feature that allows a subclass or child class to provide a specific implementation of a method that is already provided by one of its superclasses or parent classes. In C#, class methods, indexers, properties and events can all be overridden.
Method overriding and overloading are two of the most significant ways that a method differs from a conventional procedure or function call.

Eiffel (programming language)

EiffelEiffel programming languageEiffel language
In Eiffel, feature redefinition is analogous to method overriding in C++ and Java.

Class (computer programming)

classclassesPartial class
For example, the following code presents two classes, the base class, and the derived class.
Also, derived classes can override inherited methods if the language allows.

C++

C++ programming languageC++98C with Classes
C++ does not have the keyword that a subclass can use in Java to invoke a superclass version of a method that it wants to override.
Ordinarily, when a function in a derived class overrides a function in a base class, the function to call is determined by the type of the object.

Inheritance (object-oriented programming)

inheritancesuperclasssubclass
Method overriding, in object-oriented programming, is a language feature that allows a subclass or child class to provide a specific implementation of a method that is already provided by one of its superclasses or parent classes.
This process is usually called overriding.

Object-oriented programming

object-orientedobject orientedobject-oriented programming language
Method overriding, in object-oriented programming, is a language feature that allows a subclass or child class to provide a specific implementation of a method that is already provided by one of its superclasses or parent classes.

Parameter (computer programming)

parameterparametersargument
The implementation in the subclass overrides (replaces) the implementation in the superclass by providing a method that has same name, same parameters or signature, and same return type as the method in the parent class.

Object (computer science)

objectobjectsdata object
The version of a method that is executed will be determined by the object that is used to invoke it. The following statements will instantiate objects of type and, and call their respective methods:

Programmer

software developercomputer programmerdeveloper
Some languages allow a programmer to prevent a method from being overridden.

Ada (programming language)

AdaAda programming languageAda 83
Ada provides method overriding by default.

C Sharp (programming language)

C#Visual C#C# programming language
C# does support method overriding, but only if explicitly requested using the modifiers and or.

Type signature

method signaturesignaturetype annotation
When overriding one method with another, the signatures of the two methods must be identical (and with same visibility).

Indexer (programming)

indexerSubscript
In C#, class methods, indexers, properties and events can all be overridden.

Property (programming)

propertiespropertyattribute or property
In C#, class methods, indexers, properties and events can all be overridden.

Scope resolution operator

Scope resolution
Instead, the name of the parent or base class is used followed by the scope resolution operator.

Variable (computer science)

variablevariablesscalar
The method in class, by invoking the parent version of method, is also able to output the private variables and of the base class.

Statement (computer science)

statementstatementscompound statement
The following statements will instantiate objects of type and, and call their respective methods:

C++11

C++0xmove constructorconstexpr
In C++11, similar to Java, a method that is declared in the super class cannot be overridden; also, a method can be declared to make the compiler check that it overrides a method in the base class.

Delphi (software)

DelphiBorland DelphiEmbarcadero Delphi
In Delphi, method overriding is done with the directive override, but only if a method was marked with the dynamic or virtual directives.

Precondition

pre-preconditionspre-condition
When a feature is redefined, the feature name is kept by the heir class, but properties of the feature such as its signature, contract (respecting restrictions for preconditions and postconditions), and/or implementation will be different in the heir.

Postcondition

postconditionspost-conditions
When a feature is redefined, the feature name is kept by the heir class, but properties of the feature such as its signature, contract (respecting restrictions for preconditions and postconditions), and/or implementation will be different in the heir.

Java (programming language)

JavaJava programming languageJava language
In Java, when a subclass contains a method that overrides a method of the superclass, it can also invoke the superclass method by using the keyword (Lewis & Loftus, 2006).

Reserved word

keywordkeywordsreserved keyword
In Java, when a subclass contains a method that overrides a method of the superclass, it can also invoke the superclass method by using the keyword (Lewis & Loftus, 2006).