An operator is a
programming construct which modifies or derives a result from one or two
variables or
constants. In
C++, operators are defined as members of
classes,
structs, or
unions by the code
ClassName ClassName::operator + (ClassName & lh, ClassName &rh) {
// code
}
or something similar. C defines operators for several occasions, such as dereferencing (*), member dereferencing (->), and referencing (&), among many others. The following operators are legal in C (and C++):
Operators with two arguments (separated by spaces):
-> . + - * (multiplication) / % << >> < <= > >= == != ?: & ^ | && || = += -= *= /= %/ >>= <<= &= ^= |= -> .*
Operators with one argument:
:: () ++ -- ~ ! & * (dereferencing)
Also, there are two which have the form of words rather than symbols, namely sizeof and (type) (typecasting), where type is the name of an actual type, such as int, bool, or (CClientBoxDlg *). Both take one argument.
The default functionality of an operator can be overloaded by a user-defined function.