Overloading

Even for much smaller classes, this is impractical because, in general, overloading dispatches on types only and several slots can have the same type. From Cambridge English Corpus Languages without overloading or n-ary functions traditionally use list to collect optional and keyworded arguments.

Overloading
Also found in: Dictionary, Thesaurus, Medical, Financial, Acronyms, Wikipedia.

overloading

[¦ō·vər¦lōd·iŋ] (computer science)
The use, in some advanced programming languages, of two or more variables or subroutines with the same name; the compiler determines by inference which entity is referred to each time the name occurs.

overloading

(language)
(Or 'Operator overloading'). Use of a single symbol to represent operators with different argument types, e.g. '-', used either, as a monadic operator to negate an expression, or as a dyadic operator to return the difference between two expressions. Another example is '+' used to add either integers or floating-point numbers. Overloading is also known as ad-hoc polymorphism.
User-defined operator overloading is provided by several modern programming languages, e.g. C++'s class system and the functional programming language Haskell's type classes.

overloading

In programming, the ability to use the same variable for different data types. For example, the variable result could be initially filled (loaded) with a pointer and then with a string of data. See variable.
Want to thank TFD for its existence? Tell a friend about us, add a link to this page, or visit the webmaster's page for free fun content.
Link to this page:
-->

The operator keyword declares a function specifying what operator-symbol means when applied to instances of a class. This gives the operator more than one meaning, or 'overloads' it. The compiler distinguishes between the different meanings of an operator by examining the types of its operands. Sudeki gamefaqs.

Syntax

typeoperatoroperator-symbol(parameter-list)

Remarks

You can redefine the function of most built-in operators globally or on a class-by-class basis. Overloaded operators are implemented as functions.

The name of an overloaded operator is operatorx, where x is the operator as it appears in the following table. For example, to overload the addition operator, you define a function called operator+. Similarly, to overload the addition/assignment operator, +=, define a function called operator+=.

Redefinable Operators

OperatorNameType
,CommaBinary
!Logical NOTUnary
!=InequalityBinary
%ModulusBinary
%=Modulus assignmentBinary
&Bitwise ANDBinary
&Address-ofUnary
&&Logical ANDBinary
&=Bitwise AND assignmentBinary
( )Function call
( )Cast OperatorUnary
*MultiplicationBinary
*Pointer dereferenceUnary
*=Multiplication assignmentBinary
+AdditionBinary
+Unary PlusUnary
++Increment 1Unary
+=Addition assignmentBinary
-SubtractionBinary
-Unary negationUnary
--Decrement 1Unary
-=Subtraction assignmentBinary
->Member selectionBinary
->*Pointer-to-member selectionBinary
/DivisionBinary
/=Division assignmentBinary
<Less thanBinary
<<Left shiftBinary
<<=Left shift assignmentBinary
<=Less than or equal toBinary
=AssignmentBinary
EqualityBinary
>Greater thanBinary
>=Greater than or equal toBinary
>>Right shiftBinary
>>=Right shift assignmentBinary
[ ]Array subscript
^Exclusive ORBinary
^=Exclusive OR assignmentBinary
Bitwise inclusive ORBinary
=Bitwise inclusive OR assignmentBinary
Logical ORBinary
~One's complementUnary
deleteDelete
newNew
conversion operatorsconversion operatorsUnary

1 Two versions of the unary increment and decrement operators exist: preincrement and postincrement.

See General Rules for Operator Overloading for more information. The constraints on the various categories of overloaded operators are described in the following topics:

  • Increment and Decrement.

The operators shown in the following table cannot be overloaded. The table includes the preprocessor symbols # and ##.

As their feelings grow, someone from Niko’s past begins to terrorize the city. Lily Bedard, a sweet and caring young woman, sees something in Niko that he didn’t see in himself.Kate was only gone a year, it was wrong to grow close to someone else so soon, but Niko can't help the way he feels and realizes Lily is his second chance at a better life. When Lily becomes the next target, Niko will do whatever takes to keep her safe, even a the cost of his own life. Totem tribe gold firefly island.

Nonredefinable Operators

OperatorName
.Member selection
.*Pointer-to-member selection
::Scope resolution
? :Conditional
#Preprocessor convert to string
##Preprocessor concatenate

Although overloaded operators are usually called implicitly by the compiler when they are encountered in code, they can be invoked explicitly the same way as any member or nonmember function is called:

Example

The following example overloads the + operator to add two complex numbers and returns the result.

Operator

In this section

See also

C++ Built-in Operators, Precedence and Associativity
Keywords