Suppose I have a statement like :
I'm not getting any trouble with it, butCode:a.send_buffer.front().p.get_main_data();
Is is better to put parentheses ?
or is it sufficiently defined that the order should be followed ?
Printable View
Suppose I have a statement like :
I'm not getting any trouble with it, butCode:a.send_buffer.front().p.get_main_data();
Is is better to put parentheses ?
or is it sufficiently defined that the order should be followed ?
I do not think that there is any other way to evaluate the expression.
Why not?
If a similar expression contains ->* or .* or similar operators related to pointers, couldn't a function encountered later in the expression return a pointer to a member of an object encountered earlier ? I think I have seen examples like that in the Qt Documentations .
Once a function's arguments have been evaluated, a sequence point is introduced.Quote:
Originally Posted by manasij7479
Another related way to look at it: consider that we could write x.y() as y(x), if we pretend that the object on which the member function operates was passed (by reference) as the first argument to the function. This way, we could re-write a.send_buffer.front().p.get_main_data() as get_main_data(front(a.send_buffer).p). Clearly, in this form, adding parentheses isn't going to help.
Operators in C and C++ - Wikipedia, the free encyclopedia
Dot has the same precedence as () (read: the only other operator in the example) so the expression is evaluated from left to right. That's what associativity is.