Guest_imported
New member
- Jan 1, 1970
- 0
/*
Every C++ book I've read, which has an operator precedence
table, gives the post increment operator (variablename++)
higher precedence than the assignment operator (=). Some
also explain that the value isn't incremented until after the
expression is evaluated, which makes sense since it's the
"post"decrement operator, but this is hypocritical--either
it gets incremented before, as the table would indicate,
or after, as explained, but not both. Can someone resolve
this in a way that is not hypocritical?
Here's my little test program. Compiled with DJGPP, it
seems to show that the post decrement operator has
lower precedence than the assignment operator, not
higher. Are the precedence tables in the books wrong?
Yuhef
*/
#include <iostream.h>
int main(int argc, int **argv)
{
int sale = 10;
int fame = 20;
sale = (fame++);
cout << endl << "sale == " << sale << ", " << "fame == " << fame << endl;
// output: sale == 20, fame == 21
return 0;
}
Every C++ book I've read, which has an operator precedence
table, gives the post increment operator (variablename++)
higher precedence than the assignment operator (=). Some
also explain that the value isn't incremented until after the
expression is evaluated, which makes sense since it's the
"post"decrement operator, but this is hypocritical--either
it gets incremented before, as the table would indicate,
or after, as explained, but not both. Can someone resolve
this in a way that is not hypocritical?
Here's my little test program. Compiled with DJGPP, it
seems to show that the post decrement operator has
lower precedence than the assignment operator, not
higher. Are the precedence tables in the books wrong?
Yuhef
*/
#include <iostream.h>
int main(int argc, int **argv)
{
int sale = 10;
int fame = 20;
sale = (fame++);
cout << endl << "sale == " << sale << ", " << "fame == " << fame << endl;
// output: sale == 20, fame == 21
return 0;
}