J
Jeroen
Hi all,
I've got a very specific question about the evaluation order in C++.
Assume some kind of custom array class, with an overloaded subscript
operator. In the following code:
{
my_array a, b, c;
a[6] = b[5] + c[4];
}
I would assume the following order:
1) The subscript operators are evaluated for 'b' and 'c', both
returning a reference (double& for example)
2) The add-operator is called, returning a temporary object
3) The subscript operator is evaluated for 'a', returning a reference.
4) The = operator is evaluated.
My question: is this the way things go, or is this order not defined in
C++? To be more specific: is it possible that the subscript evaluation
for 'a' (step 3) is done already in step 1 (before the add-operator)?
Thanx,
Jeroen
I've got a very specific question about the evaluation order in C++.
Assume some kind of custom array class, with an overloaded subscript
operator. In the following code:
{
my_array a, b, c;
a[6] = b[5] + c[4];
}
I would assume the following order:
1) The subscript operators are evaluated for 'b' and 'c', both
returning a reference (double& for example)
2) The add-operator is called, returning a temporary object
3) The subscript operator is evaluated for 'a', returning a reference.
4) The = operator is evaluated.
My question: is this the way things go, or is this order not defined in
C++? To be more specific: is it possible that the subscript evaluation
for 'a' (step 3) is done already in step 1 (before the add-operator)?
Thanx,
Jeroen