Whats a post-fix operator
i need it to help me answer this question...
Which of the following operations has a higher PRECEDENCE: a post-fix operator or unary operator?
Whats a post-fix operator
i need it to help me answer this question...
Which of the following operations has a higher PRECEDENCE: a post-fix operator or unary operator?
int a = 5;
++a; //prefix increment operator
a++; //postfix increment operator
Check out "Operators" under the following link:
http://etude.uwaterloo.ca/~ctrudeau/...tutorial1.html
I think the answer is unary operator. If you use the - operator postfix it would be like this:
4 - 3
prefix it would be:
-4 - 3
So, if that expression gets ouput as -7, then unary has higher precedence than postfix. On the other hand, if it gets output as -1, then postfix would have higher precedence.
However, the postfix increment operator ++ is also a unary operator, in which case it would be a tie.
Last edited by 7stud; 05-31-2003 at 08:20 PM.
At Precedence Level 2:
increment operator, postfix-- x++
decrement operator, postfix-- x--
At Precedence Level 3:
All unary operators-
increment operator, prefix ++x
decrement operator, prefix --x
So this means postfix has higher precedence than prefix.
Mr. C: Author and Instructor