C++ Deck 2 Flashcards
What is an R-value?
The value that appears on the right-side operand of an assignment (=) operator.
For example, x = y has an R-value of y.
What is an L-value?
L-values are variables that appear as the left operand for an assignment (=).
For example, x = y has an L-value of x.
At this point int he course, L-values are only storage locations.
Is this a valid L-value: a+b = c
No. L-values can only be variables, they can’t contain operators.
Associativity for the Assignment Operator (=)
right-to-left
Which operator has the highest precedence of all the arithmetic operators?
- (Unary Minus)
What is the associativity of: - (unary minus)
Right-to-left
What is the associativity of +, -, *, and / arithmetic operators?
Left-to-right
When the / (division) operator is used to divide two operands which are both integer values, what will the result always be?
An integer. Any fractional portion of the answer is discarded/truncated (and NOT rounded).
True or False: The % (modulus) operator can be used and compiled in a program for non-integers.
False.
It must only be used for integers. Floating-point values with a modulus operator will not compile.
True or False: The % (modulus) operator has the same precedence as * and / operators.
True
What is the associativity of the % (modulus) operator?
Left-to-right
What is the operator precedence order among all arithmetic operators from highest to lowest?
- Parentheses and Unary Minus
- Multiplicative: *, /, %
- Additive: +, -
- Operators on the same level associate left to right.
What is the associativity of :: (Primary Scope Resolution)
left-to-right
What is the associativity of:
(), [], . , ->, dynamic_cast, typeid
(Primary)
left to right
What is the associativity of:
.* , ->*
(C++ Pointer to Member)
left-to-right