Knowledge (XXG)

Operator overloading

Source 📝

188:, and is used because it allows programming using notation nearer to the target domain and allows user-defined types a similar level of syntactic support as types built into a language. It is common, for example, in scientific computing, where it allows computing representations of mathematical objects to be manipulated with the same syntax as on paper. 1576:
supports overloading of operators from its inception, with the publication of the Ada 83 language standard. However, the language designers chose to preclude the definition of new operators. Only extant operators in the language may be overloaded, by defining new functions with identifiers such as
1064:
to the stream. Because operator overloading allows the original programmer to change the usual semantics of an operator and to catch any subsequent programmers by surprise, it is considered good practice to use operator overloading with care (the creators of
1096:). A typical counter to this argument comes directly from mathematics: While + is commutative on integers (and more generally any complex number), it is not commutative for other "types" of variables. In practice, + is not even always 1654:, the definition of all operators is delegated to lexical functions, and so, using function definitions, operators can be overloaded or new operators added. For example, the function defined in the 1112:
A classification of some common programming languages is made according to whether their operators are overloadable by the programmer and whether the operators are limited to a predefined set.
1625:
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.
1021:
Operator overloading has often been criticized because it allows programmers to reassign the semantics of operators depending on the types of their operands. For example, the use of the
1100:, for example with floating-point values due to rounding errors. Another example: In mathematics, multiplication is commutative for real and complex numbers but not commutative in 2858:
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).
1609:
allows operator overloading through the implementation of methods with special names. For example, the addition (+) operator can be overloaded by implementing the method
2712: 1710:
candidates, and "+" is only overloaded for the case where the type constraints in the function signature are met. While the capacity for overloading includes
1080:) does not always apply; an example of this occurs when the operands are strings, since + is commonly overloaded to perform a concatenation of strings (i.e. 1009:
Like with the previous examples, in the last example operator overloading is done within the class. In C++, after overloading the less-than operator (<),
1072:
Another, more subtle, issue with operators is that certain rules from mathematics can be wrongly expected or unintentionally assumed. For example, the
1824: 2466: 2605: 132: 2642: 2311: 2052: 1941: 1523:
an operator, and the programmer is free to create new operators. For dyadic operators their priority compared to other operators can be set:
1577:"+", "*", "&" etc. Subsequent revisions of the language (in 1995 and 2005) maintain the restriction to overloading of extant operators. 1862: 192: 2816: 2851: 2726: 2893: 2632: 1771: 165: 161: 24: 2534: 1634: 1296: 1188: 1183: 1178: 1754: 1606: 1376: 1359: 1336: 1326: 1306: 1272: 1168: 1644: 1223: 1213: 2341: 1651: 1616: 1596: 1386: 1381: 1331: 1316: 1252: 1208: 1139: 1066: 2580: 1982: 1622: 1573: 1341: 1291: 1198: 125: 2301: 2042: 1247: 1193: 1134: 219:
In a language that supports operator overloading, and with the usual assumption that the '*' operator has higher
2282: 1786: 1311: 1242: 1203: 1931: 195:
of a language (with functions), as it can be emulated using function calls. For example, consider variables
168:
have different implementations depending on their arguments. Operator overloading is generally defined by a
54: 1801: 1781: 1097: 2236: 2201: 2119: 1855: 1796: 1418:
Extract from the ALGOL 68 language specification (page 177) where the overloaded operators ¬, =, ≠, and
1101: 118: 1766: 1073: 208: 169: 146: 40: 2609: 2016: 220: 156: 68: 31: 2870: 2694: 2491: 2416: 1957: 1884: 1876: 106: 2105: 526:// The "const" right before the opening curly brace means that |this| is not modified. 2847: 2769: 2742: 2638: 2441: 2307: 2048: 1937: 1820: 1638: 1391: 101: 1832: 1600: 495: 91: 86: 63: 2080: 2044:
Programming F# 3.0: A Comprehensive Guide for Writing Simple Code to Solve Complex Problems
239:
In this case, the addition operator is overloaded to allow addition on a user-defined type
2820: 2755: 775:
operator defined as a class method would receive no apparent argument (it only works from
772: 185: 96: 2798: 2555: 2327: 1791: 1723: 2261: 1916: 2887: 2658: 1707: 1351: 2676: 1282: 1010: 2366: 2158: 2391: 2215: 2176: 2727:=Barry J. Mailloux "Report on the Algorithmic Language ALGOL 68, Section 10.2.2" 1355: 1267: 852:
The less-than (<) operator is often overloaded to sort a structure or class:
1647:
treats all operators as methods and thus allows operator overloading by proxy.
2067: 1776: 1277: 1257: 173: 1321: 1149: 1069:
decided not to use this feature, although not necessarily for this reason).
77: 2516: 1585: 1412: 1262: 1158: 1619:
allows operator overloading as syntactic sugar for simple method calls.
2144: 1173: 1163: 499: 2773: 1729:, and so on, it also allows for overloading various brace operators: " 1655: 1346: 1144: 1581: 1368:(using magic methods, ArrayAccess interface, or Operator extension) 1301: 1026: 244: 1237: 1218: 2634:
Computer Science & Perl Programming: Best of The Perl Journal
509:
The operation could also be defined as a class method, replacing
1371: 1060:
is an output stream then the above code will attempt to write a
2216:"Why does Go not support overloading of methods and operators?" 1706:
Since "multi" was used, the function gets added to the list of
502:. In C++, the arguments being passed are the operands, and the 231:
However, the former syntax reflects common mathematical usage.
1365: 517:
argument; However, this forces the left operand to be of type
1906:
Binary functions with a symbolic name can be called infix.
2799:"FAQ Question 6.9: Why isn't there operator overloading?" 2120:"Operators - R in a Nutshell, 2nd Edition [Book]" 223:
than the '+' operator, this is a concise way of writing:
1757:
has supported operator overloading since its creation.
2017:"3. Language Reference — Futhark 0.19.0 documentation" 2846:. Scottsdale, Arizona: Coriolis Group. p. 387. 2442:"The Apache Groovy programming language - Operators" 2300:Drayton, Peter; Albahari, Ben; Neward, Ted (2003). 1658:source for incrementing a Date object with "+" is: 1610: 1093: 1089: 1085: 1081: 1077: 1061: 1057: 1053: 1049: 1045: 1041: 1029: 1022: 776: 518: 514: 510: 503: 240: 226: 214: 204: 200: 196: 1958:"Bertrand Meyer: Basic Eiffel language mechanisms" 1933:Smalltalk and Object Orientation: An Introduction 586:// |this| should not be modified, so make a copy. 2606:"PHP magic methods overriding class properties" 2367:"Operator Overloading - D Programming Language" 1584:, operator overloading is more refined than in 1519:Note that no special declaration is needed to 126: 8: 2177:"Seed7 Manual: Structured syntax definition" 1415:specification allowed operator overloading. 2713:"How to: Define an Operator (Visual Basic)" 1425:10.2.2. Operations on Boolean Operands a) 133: 119: 20: 1936:. Springer Science & Business Media. 191:Operator overloading does not change the 1633:Microsoft added operator overloading to 1114: 2535:"Implementing Operators for Your Class" 2342:"Eclipse Ceylon: Operator Polymorphism" 1812: 76: 53: 30: 23: 2751: 2740: 2637:. O'Reilly Media, Inc. pp. 347–. 1897:Completely new operators can be added. 2871:"3. Data Model, Special method names" 16:Feature of some programming languages 7: 1090:"song" + "bird" 1082:"bird" + "song" 207:of some user-defined type, such as 1013:can be used to sort some classes. 14: 1402:Timeline of operator overloading 1040:shifts the bits in the variable 2631:Orwant, Jon (4 November 2002). 2041:Smith, Chris (9 October 2012). 1863:University of Wisconsin–Madison 1772:Polymorphism (computer science) 1056:are of an integer type, but if 2287:Annotated Ada Reference Manual 2283:"6.6 Overloading of Operators" 1930:Hunt, John (6 December 2012). 1877:"No more operator overloading" 506:object is the returned value. 1: 2875:The Python Language Reference 2774:"A History of C++: 1979−1991" 2663:The Python Language Reference 2392:"A tour of the Dart language" 1881:The Java Language Environment 2803:The comp.lang.java FAQ List 2202:"Swift: Advanced Operators" 1983:"Operator functions in F90" 1854:Fisher, Charles N. (2008). 1603:chose to omit overloading. 92:Single and dynamic dispatch 2910: 2328:"C++ Operator Overloading" 1011:standard sorting functions 2006:Introduced in Fortran 90. 1489::( a∧b ) ∨ ( ¬b∧¬a ); e) 498:, which means it has two 2842:Holzner, Steven (2001). 1660: 1611:obj.__add__(self, other) 854: 781: 523: 249: 184:Operator overloading is 160:, is a specific case of 2894:Operators (programming) 2306:. O'Reilly Media, Inc. 2070:instead of overloading. 2047:. O'Reilly Media, Inc. 1856:"Issues in Overloading" 1547:: ( a>b | a | b ); 55:Parametric polymorphism 2695:"Operator Overloading" 2581:"Operator Overloading" 2556:"Operator Overloading" 2517:"Metamethods Tutorial" 2492:"Operator overloading" 2467:"Operator Overloading" 2417:"Operator Overloading" 2021:futhark.readthedocs.io 1825:"Operator Overloading" 1802:Property (programming) 1787:Operators in C and C++ 1782:Operator (programming) 1599:language designers at 227:Add(a, Multiply(b, c)) 2181:seed7.sourceforge.net 1797:Indexer (programming) 1102:matrix multiplication 2262:"Operator Overloads" 2145:"Creating operators" 1987:www.mathcs.emory.edu 1767:Function overloading 1094:"songbird" 1086:"birdsong" 170:programming language 151:operator overloading 147:computer programming 46:Operator overloading 41:Function overloading 157:ad hoc polymorphism 153:, sometimes termed 69:Generic programming 32:Ad hoc polymorphism 2770:Stroustrup, Bjarne 2560:Free Pascal Manual 1885:Oracle Corporation 1821:Stroustrup, Bjarne 164:, where different 107:Predicate dispatch 2681:Official Ruby FAQ 2644:978-0-596-00310-4 2313:978-0-596-00526-9 2054:978-1-4493-2604-3 1943:978-1-4471-0961-7 1835:on 14 August 2011 1724:postfix and term 1688:new-from-daycount 1639:Visual Basic .NET 1516:: ( a | 1 | 0 ); 1399: 1398: 1392:Visual Basic .NET 1121:Not overloadable 143: 142: 102:Multiple dispatch 2901: 2879: 2878: 2867: 2861: 2860: 2839: 2833: 2832: 2830: 2828: 2819:. Archived from 2813: 2807: 2806: 2795: 2789: 2788: 2786: 2784: 2778: 2766: 2760: 2759: 2753: 2748: 2746: 2738: 2736: 2734: 2723: 2717: 2716: 2709: 2703: 2702: 2691: 2685: 2684: 2673: 2667: 2666: 2655: 2649: 2648: 2628: 2622: 2621: 2619: 2617: 2608:. Archived from 2602: 2596: 2595: 2593: 2591: 2577: 2571: 2570: 2568: 2566: 2552: 2546: 2545: 2543: 2541: 2531: 2525: 2524: 2513: 2507: 2506: 2504: 2502: 2488: 2482: 2481: 2479: 2477: 2463: 2457: 2456: 2454: 2452: 2438: 2432: 2431: 2429: 2427: 2413: 2407: 2406: 2404: 2402: 2388: 2382: 2381: 2379: 2377: 2363: 2357: 2356: 2354: 2352: 2338: 2332: 2331: 2324: 2318: 2317: 2303:C# in a Nutshell 2297: 2291: 2290: 2279: 2273: 2272: 2270: 2268: 2258: 2252: 2251: 2249: 2247: 2233: 2227: 2226: 2224: 2222: 2212: 2206: 2205: 2198: 2192: 2191: 2189: 2187: 2173: 2167: 2166: 2155: 2149: 2148: 2141: 2135: 2134: 2132: 2130: 2116: 2110: 2109: 2102: 2096: 2095: 2093: 2091: 2077: 2071: 2065: 2059: 2058: 2038: 2032: 2031: 2029: 2027: 2013: 2007: 2004: 1998: 1997: 1995: 1993: 1979: 1973: 1972: 1970: 1968: 1954: 1948: 1947: 1927: 1921: 1920: 1917:"Predicate op/3" 1913: 1907: 1904: 1898: 1895: 1889: 1888: 1873: 1867: 1866: 1860: 1851: 1845: 1844: 1842: 1840: 1831:. Archived from 1817: 1701: 1697: 1693: 1689: 1685: 1681: 1678: 1674: 1671: 1667: 1664: 1612: 1601:Sun Microsystems 1115: 1095: 1091: 1087: 1083: 1079: 1076:of + (i.e. that 1063: 1059: 1055: 1051: 1047: 1043: 1039: 1038: 1035: 1032: 1024: 1005: 1002: 999: 996: 993: 990: 987: 984: 981: 978: 975: 972: 969: 966: 963: 960: 957: 954: 951: 948: 945: 942: 939: 936: 933: 930: 927: 924: 921: 918: 915: 912: 909: 906: 903: 900: 897: 894: 891: 888: 885: 882: 879: 876: 873: 870: 867: 864: 861: 858: 848: 845: 842: 839: 836: 833: 830: 827: 824: 821: 818: 815: 812: 809: 806: 803: 800: 797: 794: 791: 788: 785: 778: 767: 764: 761: 758: 755: 752: 749: 746: 743: 740: 737: 734: 731: 728: 725: 722: 719: 716: 713: 710: 707: 704: 701: 698: 695: 692: 689: 686: 683: 680: 677: 674: 671: 668: 665: 662: 659: 656: 653: 650: 647: 644: 641: 638: 635: 632: 629: 626: 623: 620: 617: 614: 611: 608: 605: 602: 599: 596: 593: 590: 587: 584: 581: 578: 575: 572: 569: 566: 563: 560: 557: 554: 551: 548: 545: 542: 539: 536: 533: 530: 527: 520: 516: 512: 505: 496:binary operation 490: 487: 484: 481: 478: 475: 472: 469: 466: 463: 460: 457: 454: 451: 448: 445: 442: 439: 436: 433: 430: 427: 424: 421: 418: 415: 412: 409: 406: 403: 400: 397: 394: 391: 388: 385: 382: 379: 376: 373: 370: 367: 364: 361: 358: 355: 352: 349: 346: 343: 340: 337: 334: 331: 328: 325: 322: 319: 316: 313: 310: 307: 304: 301: 298: 295: 292: 289: 286: 283: 280: 277: 274: 271: 268: 265: 262: 259: 256: 253: 242: 228: 216: 206: 202: 198: 193:expressive power 135: 128: 121: 87:Virtual function 64:Generic function 21: 2909: 2908: 2904: 2903: 2902: 2900: 2899: 2898: 2884: 2883: 2882: 2869: 2868: 2864: 2854: 2844:C++: Black Book 2841: 2840: 2836: 2826: 2824: 2823:on 7 March 2009 2815: 2814: 2810: 2797: 2796: 2792: 2782: 2780: 2776: 2768: 2767: 2763: 2749: 2739: 2732: 2730: 2725: 2724: 2720: 2711: 2710: 2706: 2699:Rust By Example 2693: 2692: 2688: 2675: 2674: 2670: 2659:"3. Data Model" 2657: 2656: 2652: 2645: 2630: 2629: 2625: 2615: 2613: 2612:on 4 March 2016 2604: 2603: 2599: 2589: 2587: 2579: 2578: 2574: 2564: 2562: 2554: 2553: 2549: 2539: 2537: 2533: 2532: 2528: 2515: 2514: 2510: 2500: 2498: 2490: 2489: 2485: 2475: 2473: 2465: 2464: 2460: 2450: 2448: 2446:groovy-lang.org 2440: 2439: 2435: 2425: 2423: 2415: 2414: 2410: 2400: 2398: 2390: 2389: 2385: 2375: 2373: 2365: 2364: 2360: 2350: 2348: 2346:ceylon-lang.org 2340: 2339: 2335: 2326: 2325: 2321: 2314: 2299: 2298: 2294: 2281: 2280: 2276: 2266: 2264: 2260: 2259: 2255: 2245: 2243: 2235: 2234: 2230: 2220: 2218: 2214: 2213: 2209: 2200: 2199: 2195: 2185: 2183: 2175: 2174: 2170: 2157: 2156: 2152: 2143: 2142: 2138: 2128: 2126: 2124:www.oreilly.com 2118: 2117: 2113: 2104: 2103: 2099: 2089: 2087: 2079: 2078: 2074: 2066: 2062: 2055: 2040: 2039: 2035: 2025: 2023: 2015: 2014: 2010: 2005: 2001: 1991: 1989: 1981: 1980: 1976: 1966: 1964: 1956: 1955: 1951: 1944: 1929: 1928: 1924: 1915: 1914: 1910: 1905: 1901: 1896: 1892: 1875: 1874: 1870: 1858: 1853: 1852: 1848: 1838: 1836: 1819: 1818: 1814: 1810: 1763: 1704: 1703: 1699: 1695: 1691: 1687: 1683: 1679: 1676: 1672: 1669: 1666:infix:<+> 1665: 1662: 1637:in 2001 and to 1631: 1594: 1571: 1566: 1565:: ( a +:= 1 ); 1517: 1409: 1404: 1110: 1036: 1033: 1030: 1019: 1007: 1006: 1003: 1000: 997: 994: 991: 988: 985: 982: 979: 976: 973: 970: 967: 964: 961: 958: 955: 952: 949: 946: 943: 940: 937: 934: 931: 928: 925: 922: 919: 916: 913: 910: 907: 904: 901: 898: 895: 892: 889: 886: 883: 880: 877: 874: 871: 868: 865: 862: 859: 856: 850: 849: 846: 843: 840: 837: 834: 831: 828: 825: 822: 819: 816: 813: 810: 807: 804: 801: 798: 795: 792: 789: 786: 783: 769: 768: 765: 762: 759: 756: 753: 750: 747: 744: 741: 738: 735: 732: 729: 726: 723: 720: 717: 714: 711: 708: 705: 702: 699: 696: 693: 690: 687: 684: 681: 678: 675: 672: 669: 666: 663: 660: 657: 654: 651: 648: 645: 642: 639: 636: 633: 630: 627: 624: 621: 618: 615: 612: 609: 606: 603: 600: 597: 594: 591: 588: 585: 582: 579: 576: 573: 570: 567: 564: 561: 558: 555: 552: 549: 546: 543: 540: 537: 534: 531: 528: 525: 492: 491: 488: 485: 482: 479: 476: 473: 470: 467: 464: 461: 458: 455: 452: 449: 446: 443: 440: 437: 434: 431: 428: 425: 422: 419: 416: 413: 410: 407: 404: 401: 398: 395: 392: 389: 386: 383: 380: 377: 374: 371: 368: 365: 362: 359: 356: 353: 350: 347: 344: 341: 338: 335: 332: 329: 326: 323: 320: 317: 314: 311: 308: 305: 302: 299: 296: 293: 290: 287: 284: 281: 278: 275: 272: 269: 266: 263: 260: 257: 254: 251: 237: 186:syntactic sugar 182: 139: 97:Double dispatch 17: 12: 11: 5: 2907: 2905: 2897: 2896: 2886: 2885: 2881: 2880: 2862: 2852: 2834: 2817:"java.sun.com" 2808: 2790: 2761: 2718: 2704: 2686: 2668: 2650: 2643: 2623: 2597: 2572: 2547: 2526: 2521:Lua-users Wiki 2508: 2483: 2458: 2433: 2408: 2383: 2358: 2333: 2319: 2312: 2292: 2274: 2253: 2241:freepascal.org 2237:"Introduction" 2228: 2207: 2193: 2168: 2150: 2136: 2111: 2097: 2085:iolanguage.org 2072: 2060: 2053: 2033: 2008: 1999: 1974: 1949: 1942: 1922: 1908: 1899: 1890: 1868: 1846: 1811: 1809: 1806: 1805: 1804: 1799: 1794: 1792:Mutator method 1789: 1784: 1779: 1774: 1769: 1762: 1759: 1661: 1630: 1627: 1593: 1590: 1570: 1567: 1525: 1424: 1408: 1405: 1403: 1400: 1397: 1396: 1395: 1394: 1389: 1384: 1379: 1374: 1369: 1363: 1349: 1344: 1339: 1334: 1329: 1324: 1319: 1314: 1309: 1304: 1299: 1294: 1287: 1286: 1285: 1280: 1275: 1270: 1265: 1260: 1255: 1250: 1245: 1240: 1233: 1229: 1228: 1227: 1226: 1221: 1216: 1211: 1206: 1201: 1196: 1191: 1186: 1181: 1176: 1171: 1166: 1161: 1154: 1153: 1152: 1147: 1142: 1137: 1130: 1129:New definable 1126: 1125: 1122: 1119: 1109: 1106: 1078:a + b == b + a 1018: 1015: 855: 782: 524: 513:by the hidden 494:Addition is a 250: 236: 233: 181: 178: 141: 140: 138: 137: 130: 123: 115: 112: 111: 110: 109: 104: 99: 94: 89: 81: 80: 74: 73: 72: 71: 66: 58: 57: 51: 50: 49: 48: 43: 35: 34: 28: 27: 15: 13: 10: 9: 6: 4: 3: 2: 2906: 2895: 2892: 2891: 2889: 2876: 2872: 2866: 2863: 2859: 2855: 2853:1-57610-777-9 2849: 2845: 2838: 2835: 2822: 2818: 2812: 2809: 2804: 2800: 2794: 2791: 2775: 2771: 2765: 2762: 2757: 2744: 2729:. August 1968 2728: 2722: 2719: 2714: 2708: 2705: 2700: 2696: 2690: 2687: 2682: 2678: 2672: 2669: 2664: 2660: 2654: 2651: 2646: 2640: 2636: 2635: 2627: 2624: 2611: 2607: 2601: 2598: 2586: 2585:Delphi Manual 2582: 2576: 2573: 2561: 2557: 2551: 2548: 2536: 2530: 2527: 2522: 2518: 2512: 2509: 2497: 2493: 2487: 2484: 2472: 2468: 2462: 2459: 2447: 2443: 2437: 2434: 2422: 2418: 2412: 2409: 2397: 2393: 2387: 2384: 2372: 2368: 2362: 2359: 2347: 2343: 2337: 2334: 2329: 2323: 2320: 2315: 2309: 2305: 2304: 2296: 2293: 2288: 2284: 2278: 2275: 2263: 2257: 2254: 2242: 2238: 2232: 2229: 2217: 2211: 2208: 2203: 2197: 2194: 2182: 2178: 2172: 2169: 2164: 2163:Tour of Scala 2160: 2154: 2151: 2146: 2140: 2137: 2125: 2121: 2115: 2112: 2107: 2101: 2098: 2086: 2082: 2076: 2073: 2069: 2064: 2061: 2056: 2050: 2046: 2045: 2037: 2034: 2022: 2018: 2012: 2009: 2003: 2000: 1988: 1984: 1978: 1975: 1963: 1959: 1953: 1950: 1945: 1939: 1935: 1934: 1926: 1923: 1918: 1912: 1909: 1903: 1900: 1894: 1891: 1886: 1882: 1878: 1872: 1869: 1864: 1857: 1850: 1847: 1834: 1830: 1826: 1822: 1816: 1813: 1807: 1803: 1800: 1798: 1795: 1793: 1790: 1788: 1785: 1783: 1780: 1778: 1775: 1773: 1770: 1768: 1765: 1764: 1760: 1758: 1756: 1752: 1750: 1746: 1742: 1740: 1734: 1731: 1728: 1727: 1721: 1717: 1713: 1709: 1708:multidispatch 1659: 1657: 1653: 1648: 1646: 1642: 1640: 1636: 1628: 1626: 1624: 1620: 1618: 1614: 1608: 1604: 1602: 1598: 1591: 1589: 1587: 1583: 1578: 1575: 1568: 1564: 1560: 1557: 1553: 1550: 1546: 1542: 1538: 1535: 1531: 1528: 1524: 1522: 1515: 1511: 1507: 1504: 1501:: ¬(a=b); f) 1500: 1496: 1492: 1488: 1484: 1480: 1476: 1472: 1468: 1464: 1460: 1456: 1452: 1448: 1444: 1440: 1436: 1432: 1428: 1423: 1422:are defined: 1421: 1416: 1414: 1406: 1401: 1393: 1390: 1388: 1385: 1383: 1380: 1378: 1375: 1373: 1370: 1367: 1364: 1362:(since 2005)) 1361: 1357: 1353: 1352:Object Pascal 1350: 1348: 1345: 1343: 1340: 1338: 1335: 1333: 1330: 1328: 1325: 1323: 1320: 1318: 1315: 1313: 1310: 1308: 1305: 1303: 1300: 1298: 1295: 1293: 1290: 1289: 1288: 1284: 1281: 1279: 1276: 1274: 1271: 1269: 1266: 1264: 1261: 1259: 1256: 1254: 1251: 1249: 1246: 1244: 1241: 1239: 1236: 1235: 1234: 1231: 1230: 1225: 1222: 1220: 1217: 1215: 1212: 1210: 1207: 1205: 1202: 1200: 1197: 1195: 1192: 1190: 1187: 1185: 1182: 1180: 1177: 1175: 1172: 1170: 1167: 1165: 1162: 1160: 1157: 1156: 1155: 1151: 1148: 1146: 1143: 1141: 1138: 1136: 1133: 1132: 1131: 1128: 1127: 1124:Overloadable 1123: 1120: 1117: 1116: 1113: 1107: 1105: 1103: 1099: 1075: 1074:commutativity 1070: 1068: 1028: 1016: 1014: 1012: 853: 780: 774: 522: 507: 501: 497: 248: 246: 234: 232: 229: 224: 222: 217: 212: 210: 194: 189: 187: 179: 177: 175: 171: 167: 163: 159: 158: 152: 148: 136: 131: 129: 124: 122: 117: 116: 114: 113: 108: 105: 103: 100: 98: 95: 93: 90: 88: 85: 84: 83: 82: 79: 75: 70: 67: 65: 62: 61: 60: 59: 56: 52: 47: 44: 42: 39: 38: 37: 36: 33: 29: 26: 22: 19: 2874: 2865: 2857: 2843: 2837: 2825:. Retrieved 2821:the original 2811: 2802: 2793: 2781:. Retrieved 2779:. p. 12 2764: 2731:. Retrieved 2721: 2707: 2698: 2689: 2680: 2671: 2662: 2653: 2633: 2626: 2614:. Retrieved 2610:the original 2600: 2588:. Retrieved 2584: 2575: 2563:. Retrieved 2559: 2550: 2538:. Retrieved 2529: 2520: 2511: 2499:. Retrieved 2495: 2486: 2474:. Retrieved 2470: 2461: 2451:30 September 2449:. Retrieved 2445: 2436: 2424:. Retrieved 2420: 2411: 2401:30 September 2399:. Retrieved 2395: 2386: 2374:. Retrieved 2370: 2361: 2349:. Retrieved 2345: 2336: 2322: 2302: 2295: 2286: 2277: 2267:28 September 2265:. Retrieved 2256: 2246:30 September 2244:. Retrieved 2240: 2231: 2219:. Retrieved 2210: 2196: 2186:29 September 2184:. Retrieved 2180: 2171: 2162: 2153: 2139: 2127:. Retrieved 2123: 2114: 2100: 2088:. Retrieved 2084: 2075: 2068:Type classes 2063: 2043: 2036: 2024:. Retrieved 2020: 2011: 2002: 1990:. Retrieved 1986: 1977: 1965:. Retrieved 1961: 1952: 1932: 1925: 1911: 1902: 1893: 1880: 1871: 1849: 1837:. Retrieved 1833:the original 1828: 1815: 1753: 1748: 1744: 1738: 1736: 1733: 1730: 1725: 1719: 1715: 1711: 1705: 1649: 1643: 1632: 1621: 1615: 1605: 1595: 1579: 1572: 1562: 1558: 1555: 1551: 1548: 1544: 1540: 1536: 1533: 1529: 1526: 1520: 1518: 1513: 1509: 1505: 1502: 1498: 1494: 1490: 1486: 1482: 1478: 1474: 1470: 1466: 1462: 1458: 1454: 1453:: ( a | b | 1450: 1446: 1442: 1438: 1434: 1430: 1426: 1419: 1417: 1410: 1283:Visual Basic 1232:Limited set 1111: 1071: 1025:operator in 1020: 1008: 851: 771:Note that a 770: 508: 493: 238: 230: 225: 218: 213: 190: 183: 162:polymorphism 154: 150: 144: 45: 25:Polymorphism 18: 2421:bourabai.kz 2221:4 September 2159:"Operators" 2106:"Operators" 1356:Free Pascal 1268:Objective-C 1098:associative 176:, or both. 2752:|url= 2590:1 December 2565:1 December 2376:10 October 2081:"io guide" 2026:10 October 1962:se.ethz.ch 1808:References 1777:Subroutine 1441:| b ); b) 1278:TypeScript 1258:JavaScript 1118:Operators 1017:Criticisms 832:&& 820:&& 221:precedence 180:Rationale 174:programmer 2677:"Methods" 2540:1 October 2371:dlang.org 1839:27 August 1743:", and "x 1641:in 2003. 1322:FreeBASIC 1150:Smalltalk 215:a + b * c 166:operators 155:operator 78:Subtyping 2888:Category 2827:26 March 2743:cite web 2471:Manifold 2396:dart.dev 1761:See also 1696:daycount 1682:) { 1586:ALGOL 68 1521:overload 1469:: ( a | 1413:ALGOL 68 1263:Modula-2 1159:ALGOL 68 1088:, while 1048:bits if 1044:left by 1034:<< 1023:<< 875:operator 793:operator 538:operator 500:operands 255:operator 235:Examples 209:matrices 2783:1 April 2754:value ( 2733:1 April 2616:7 April 2501:24 June 2426:7 April 2351:7 April 2129:7 April 2090:7 April 1992:7 April 1967:7 April 1829:C++ FAQ 1437::( a | 1189:Haskell 1179:Futhark 1174:Fortran 1164:Clojure 1108:Catalog 1092:yields 1084:yields 980:private 835:seconds 823:minutes 721:minutes 703:minutes 679:minutes 667:minutes 649:seconds 631:seconds 619:minutes 607:seconds 595:seconds 444:minutes 426:minutes 402:minutes 390:minutes 372:seconds 354:seconds 342:minutes 330:seconds 318:seconds 2850:  2750:Check 2641:  2496:Kotlin 2476:7 June 2310:  2051:  1940:  1755:Kotlin 1722:, the 1670:Date:D 1656:Rakudo 1607:Python 1543:a, b) 1532:= 9; 1497:a, b) 1485:a, b) 1477:); d) 1457:); c) 1449:a, b) 1433:a, b) 1377:Python 1360:Delphi 1347:MATLAB 1337:Kotlin 1327:Groovy 1307:Ceylon 1273:Pascal 1169:Eiffel 1145:Prolog 956:return 932:return 866:public 808:return 757:return 480:return 2777:(PDF) 1859:(PDF) 1735:", "x 1732:", "x 1720:>= 1677:Int:D 1663:multi 1645:Scala 1629:2000s 1592:1990s 1569:1980s 1493:≠ = ( 1481:= = ( 1471:false 1461:¬ = ( 1455:false 1445:∧ = ( 1429:∨ = ( 1407:1960s 1238:BASIC 1224:Swift 1219:Seed7 1214:Scala 899:const 890:& 884:const 857:class 811:hours 802:const 773:unary 751:hours 739:hours 691:hours 562:const 553:& 547:const 474:hours 462:hours 414:hours 285:& 279:const 270:& 264:const 2848:ISBN 2829:2009 2785:2007 2756:help 2735:2007 2639:ISBN 2618:2015 2592:2014 2567:2014 2542:2013 2503:2018 2478:2020 2453:2020 2428:2021 2403:2020 2378:2020 2353:2021 2308:ISBN 2269:2018 2248:2020 2223:2011 2188:2020 2131:2021 2092:2021 2049:ISBN 2028:2020 1994:2021 1969:2021 1938:ISBN 1841:2020 1702:) } 1684:Date 1652:Raku 1617:Ruby 1597:Java 1561:a ) 1554:= ( 1527:prio 1510:bool 1499:bool 1495:bool 1487:bool 1483:bool 1475:true 1467:bool 1463:bool 1451:bool 1447:bool 1439:true 1435:bool 1431:bool 1411:The 1387:Rust 1382:Ruby 1372:Perl 1332:Java 1317:Dart 1253:Java 1209:Raku 1140:Pico 1067:Java 1052:and 962:< 938:< 887:Pair 878:< 872:bool 860:Pair 787:Time 784:bool 777:this 760:temp 733:temp 715:temp 697:temp 685:temp 661:temp 643:temp 625:temp 613:temp 589:temp 580:this 571:temp 568:Time 550:Time 532:Time 529:Time 519:Time 515:this 504:temp 483:temp 456:temp 438:temp 420:temp 408:temp 384:temp 366:temp 348:temp 336:temp 312:temp 300:temp 297:Time 282:Time 267:Time 252:Time 241:Time 203:and 172:, a 1751:". 1700:$ x 1692:$ d 1680:$ x 1673:$ d 1650:In 1623:Lua 1582:C++ 1580:In 1574:Ada 1563:int 1559:int 1556:ref 1545:int 1541:int 1539:= ( 1537:max 1530:max 1514:int 1508:= ( 1506:abs 1465:a) 1420:abs 1366:PHP 1342:Lua 1302:C++ 1292:Ada 1199:Nim 1027:C++ 995:int 986:int 779:): 745:rhs 673:rhs 601:rhs 556:rhs 511:lhs 468:rhs 396:rhs 324:rhs 306:lhs 288:rhs 273:lhs 245:C++ 243:in 145:In 2890:: 2873:. 2856:. 2801:. 2772:. 2747:: 2745:}} 2741:{{ 2697:. 2679:. 2661:. 2583:. 2558:. 2519:. 2494:. 2469:. 2444:. 2419:. 2394:. 2369:. 2344:. 2285:. 2239:. 2179:. 2161:. 2122:. 2083:. 2019:. 1985:. 1960:. 1883:. 1879:. 1861:. 1827:. 1823:. 1718:, 1714:, 1698:+ 1675:, 1635:C# 1613:. 1588:. 1552:++ 1549:op 1534:op 1512:a) 1503:op 1491:op 1479:op 1473:| 1459:op 1443:op 1427:op 1358:, 1297:C# 1248:Go 1194:Io 1184:F# 1135:ML 1104:. 1004:}; 998:y_ 989:x_ 971:x_ 959:x_ 947:y_ 935:y_ 923:x_ 914:== 911:x_ 905:if 838:== 826:== 814:== 799:() 790::: 742:+= 727:60 724:%= 709:60 694:+= 670:+= 655:60 652:%= 637:60 622:+= 598:+= 535::: 521:: 465:+= 450:60 447:%= 432:60 417:+= 393:+= 378:60 375:%= 360:60 345:+= 321:+= 247:: 211:: 199:, 149:, 2877:. 2831:. 2805:. 2787:. 2758:) 2737:. 2715:. 2701:. 2683:. 2665:. 2647:. 2620:. 2594:. 2569:. 2544:. 2523:. 2505:. 2480:. 2455:. 2430:. 2405:. 2380:. 2355:. 2330:. 2316:. 2289:. 2271:. 2250:. 2225:. 2204:. 2190:. 2165:. 2147:. 2133:. 2108:. 2094:. 2057:. 2030:. 1996:. 1971:. 1946:. 1919:. 1887:. 1865:. 1843:. 1749:) 1747:y 1745:( 1741:} 1739:y 1737:{ 1726:i 1716:* 1712:+ 1694:. 1690:( 1686:. 1668:( 1354:( 1312:D 1243:C 1204:R 1062:b 1058:a 1054:b 1050:a 1046:b 1042:a 1037:b 1031:a 1001:; 992:; 983:: 977:} 974:; 968:. 965:p 953:} 950:; 944:. 941:p 929:{ 926:) 920:. 917:p 908:( 902:{ 896:) 893:p 881:( 869:: 863:{ 847:} 844:; 841:0 829:0 817:0 805:{ 796:! 766:} 763:; 754:; 748:. 736:. 730:; 718:. 712:; 706:/ 700:. 688:. 682:; 676:. 664:. 658:; 646:. 640:; 634:/ 628:. 616:. 610:; 604:. 592:. 583:; 577:* 574:= 565:{ 559:) 544:( 541:+ 489:} 486:; 477:; 471:. 459:. 453:; 441:. 435:; 429:/ 423:. 411:. 405:; 399:. 387:. 381:; 369:. 363:; 357:/ 351:. 339:. 333:; 327:. 315:. 309:; 303:= 294:{ 291:) 276:, 261:( 258:+ 205:c 201:b 197:a 134:e 127:t 120:v

Index

Polymorphism
Ad hoc polymorphism
Function overloading
Operator overloading
Parametric polymorphism
Generic function
Generic programming
Subtyping
Virtual function
Single and dynamic dispatch
Double dispatch
Multiple dispatch
Predicate dispatch
v
t
e
computer programming
ad hoc polymorphism
polymorphism
operators
programming language
programmer
syntactic sugar
expressive power
matrices
precedence
C++
binary operation
operands
unary

Text is available under the Creative Commons Attribution-ShareAlike License. Additional terms may apply.