Say we have class A :
class A { public: A& func1( int ) { return *this; } A& func2( int ) { return *this; } };
and 2 separate functions:
int func3(); int func4();
now in this code:
A a; a.func1( func3() ).func2( func4() );
- the order of evaluation of functions func3() and func4() defined?
According to this answer, Undefined behavior and sequence points are one of the points in the sequence:
- when calling a function (regardless of whether the function is built-in), after evaluating all the arguments of the function (if any) that are executed before executing any expressions or statements in the body of the function (
ยง1.9/17 ).
So, "evaluating all the arguments of the function" means that func3() needs to be called before func4() , since the evaluation of the arguments func1() must occur before calling func2() ?
c ++ order-of-evaluation
Slava
source share