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.
Syntax
typeoperator
operator-symbol(parameter-list)
Remarks
Me singing with my family The Wallens at MAGMA (Mid America Gospel Music Association) We sang 'Operator' and my other side of the family The Lesters came out and sang with us at the end.
Rm908, 9/f, yan hing centre 9-13 wong chuk yeung street, fo tan, shatin, n.t. Listen to music from Operator like Nothing To Lose, Soulcrusher & more. Find the latest tracks, albums, and images from Operator. Listen to songs and albums by Operator Music Band, including 'Mondo,' 'Slim Spin,' 'Nul,' and many more. Songs by Operator Music Band start at $0.99.
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 operator
x, 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+=.
Operator's Soundtrack Download Torrent
Redefinable Operators
Operator | Name | Type |
---|---|---|
, | Comma | Binary |
! | Logical NOT | Unary |
!= | Inequality | Binary |
% | Modulus | Binary |
%= | Modulus assignment | Binary |
& | Bitwise AND | Binary |
& | Address-of | Unary |
&& | Logical AND | Binary |
&= | Bitwise AND assignment | Binary |
( ) | Function call | — |
( ) | Cast Operator | Unary |
* | Multiplication | Binary |
* | Pointer dereference | Unary |
*= | Multiplication assignment | Binary |
+ | Addition | Binary |
+ | Unary Plus | Unary |
++ | Increment 1 | Unary |
+= | Addition assignment | Binary |
- | Subtraction | Binary |
- | Unary negation | Unary |
-- | Decrement 1 | Unary |
-= | Subtraction assignment | Binary |
-> | Member selection | Binary |
->* | Pointer-to-member selection | Binary |
/ | Division | Binary |
/= | Division assignment | Binary |
< | Less than | Binary |
<< | Left shift | Binary |
<<= | Left shift assignment | Binary |
<= | Less than or equal to | Binary |
= | Assignment | Binary |
Equality | Binary | |
> | Greater than | Binary |
>= | Greater than or equal to | Binary |
>> | Right shift | Binary |
>>= | Right shift assignment | Binary |
[ ] | Array subscript | — |
^ | Exclusive OR | Binary |
^= | Exclusive OR assignment | Binary |
| | Bitwise inclusive OR | Binary |
|= | Bitwise inclusive OR assignment | Binary |
|| | Logical OR | Binary |
~ | One's complement | Unary |
delete | Delete | — |
new | New | — |
conversion operators | conversion operators | Unary |
Operator's Soundtrack Download Free
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 ##.
Nonredefinable Operators
Operator | Name |
---|---|
. | 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.
In this section
See also
C++ Built-in Operators, Precedence and Associativity
Keywords