Assignment Operators
From RAD Studio
Go Up to Binary Operators Index
Syntax
unary-expression assignment-op assignment-expression
Remarks
The assignment operators are:
= *= /= %= += -= <<= >>= &= ^= |=
The = operator is the only simple assignment operator, the others are compound assignment operators.
In the expression E1 = E2, E1 must be a modifiable lvalue. The assignment expression itself is not an lvalue.
The expression
E1 op= E2
has the same effect as
E1 = E1 op E2
except the lvalue E1 is evaluated only once. For example, E1 += E2 is the same as E1 = E1 + E2.
The expression's value is E1 after the expression evaluates.
For both simple and compound assignment, the operands E1 and E2 must obey one of the following rules:
-
E1is a qualified or unqualified arithmetic type andE2is an arithmetic type. -
E1has a qualified or unqualified version of a structure or union type compatible with the type ofE2. -
E1andE2are pointers to qualified or unqualified versions of compatible types, and the type pointed to by the left has all the qualifiers of the type pointed to by the right. - Either
E1orE2is a pointer to an object or incomplete type and the other is a pointer to a qualified or unqualified version of void. The type pointed to by the left has all the qualifiers of the type pointed to by the right. -
E1is a pointer andE2is a null pointer constant.
Note: Spaces separating compound operators (+<space>=) will generate errors.
Note: There are certain conditions where assignment operators are not supported when used with properties.