C++ does not define evaluation order of function parameters.
In:
f( g(), h(), i(), j() )
, functions g,h,i and j may be evaluated in any order.
Same for operators:
std::cout << x() << y() << z();
, where x, y and z may be evaluated in any order, same for operators.
One solution to this is to use initialization lists:
class MyClass_Double{public: double A, B; MyClass_Double() : A(rand()) , B(rand()) {}};class MyClass_Int{public: int A, B; MyClass_Int() : A(rand()) , B(rand()) {}};
Here, C++ must evaluate the arguments in order of declaration.