Languages Features Calendar CSV Lists Blog About Sponsor Add Language
GitHub icon

Operator Overloading

Operator Overloading

Operator Overloading is a feature.

Where different operators have different implementations depending on their arguments.

Languages without Operator Overloading include Java, JavaScript, C, Go, Pascal, TypeScript, Visual Basic, Objective-C, Modula-2, BASIC, Jule

Languages with Operator Overloading include Python, C++, PHP, Perl, MATLAB, C#, Ruby, R, Swift, Scala, Rust, Haskell, Ada, Lua, Clojure, Kotlin, Dart, F#, Eiffel, D, Smalltalk, Groovy, Visual Basic .NET, Ceylon, Io, Object Pascal, Perl 6, Wolfram Language, Seed7, Free Pascal, FreeBASIC

Example from Python:
# Python Program illustrate how # to overload an binary + operator class A: def __init__(self, a): self.a = a # adding two objects def __add__(self, o): return self.a + o.a ob1 = A(1) ob2 = A(2) ob3 = A("Geeks") ob4 = A("For") print(ob1 + ob2) print(ob3 + ob4)
Example from Wolfram Language:
f[x_Integer] := x^2; f[x_String] := "not a number"; f[x_Symbol] := x^2;
mixin-feature.html 路 operator-overloading-feature.html 路 pointers-feature.html

View source

PLDB - Build the next great programming language 路 v2022 Day 33 Docs Build Acknowledgements Traffic Today Traffic Trends Mirrors GitHub