c/c++ 运算符的优先级和结合性ZZ 2010-05-18 15:29 Precedence Operator Description Example Associativity 1 () [] ->
:: ++ -- Grouping operator Array access Member access from a pointer Member access from an object Scoping operator Post-increment Post-decrement (a + b) / 4; array[4] = 2; ptr->age = 34; obj
age = 34; Class::age = 2; for( i = 0; i < 10; i++ )
for( i = 10; i > 0; i-- )
left to right 2
~ ++ -- - + * & (type) sizeof Logical negation Bitwise complement Pre-increment Pre-decrement Unary minus Unary plus Dereference Address of Cast to a given type Return size in bytes if(
done )
flags = ~flags; for( i = 0; i < 10; ++i )
for( i = 10; i > 0; --i )
int i = -1; int i = +1; data = *ptr; address = &obj; int i = (int) floatNum; int size = sizeof(floatNum); right to left 3 ->*