Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
Operator overloading
(section)
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
===1990s=== [[Java (programming language)|Java]] language designers at [[Sun Microsystems]] chose to omit overloading.<ref>{{cite web |url=http://www.cafeaulait.org/javafaq.html#xtocid1902938 |website=The comp.lang.java FAQ List |title=FAQ Question 6.9: Why isn't there operator overloading?}}</ref><ref>{{cite web |url=http://java.sun.com/docs/white/langenv/Simple.doc2.html |title=java.sun.com |url-status=dead |access-date=26 March 2009 |archive-date=7 March 2009 |archive-url=https://web.archive.org/web/20090307035128/http://java.sun.com/docs/white/langenv/Simple.doc2.html }}</ref><ref>{{cite book |last=Holzner |first=Steven |title=C++: Black Book |year=2001 |publisher=Coriolis Group |location=Scottsdale, Arizona |isbn=1-57610-777-9 |page=387 |quote=One of the nicest features of C++ OOP is that you can overload operators to handle objects of your classes (you can't do this in some other OOP-centric languages, like Java).}}</ref> [[Python (programming language)|Python]] allows operator overloading through the implementation of methods with special names.<ref>{{cite web |url=https://docs.python.org/3/reference/datamodel.html#specialnames |website=The Python Language Reference |title=3. Data Model, Special method names}}</ref> For example, the addition (+) operator can be overloaded by implementing the method {{code|obj.__add__(self, other)}}. [[Ruby (programming language)|Ruby]] allows operator overloading as syntactic sugar for simple method calls. [[Lua (programming language)|Lua]] allows operator overloading as syntactic sugar for method calls with the added feature that if the first operand doesn't define that operator, the method for the second operand will be used.
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)