home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / snip9707.zip / C_PREC.TXT < prev    next >
Text File  |  1997-07-05  |  5KB  |  82 lines

  1. +++Date last modified: 05-Jul-1997
  2.  
  3.           Operator Precedence and Associativity Rules in C / C++
  4.  ============================================================================
  5.     ::        scope resolution (C++, e.g. name::member)     left-to-right
  6.     ::        global (C++, e.g. ::name)
  7.  ----------------------------------------------------------------------------
  8.     ( )       function call                                 left-to-right
  9.     [ ]       array element
  10.      .        class, structure or union member
  11.     ->        pointer reference to member
  12.     ::        scope access / resolution (C++)
  13.   sizeof      size of object in bytes
  14.   sizeof      size of type in bytes
  15.  ============================================================================
  16.  NOTE: In C the following operators have the same precedence as those in
  17.        the preceding group. In C++, they have the same precedence as those
  18.        in the following group.
  19.  ----------------------------------------------------------------------------
  20.     ++        post increment (lvalue++)                     right-to-left
  21.     --        post decrement (lvalue--)
  22.  ============================================================================
  23.     ++        pre increment (++lvalue)                      right-to-left
  24.     --        pre decrement (--lvalue)
  25.      ~        bitwise complement
  26.      !        logical not
  27.      -        unary minus
  28.      +        unary plus
  29.      &        address of
  30.      *        contents of
  31.     new       create object (C++)
  32.   delete      destroy object (C++)
  33.   delete[]    destroy array (C++)
  34.   (type)      cast to type
  35.  ----------------------------------------------------------------------------
  36.     .*        member pointer (C++)                          left-to-right
  37.     ->*       pointer reference to member pointer (C++)
  38.  ----------------------------------------------------------------------------
  39.      *        multiply                                      left-to-right
  40.      /        divide
  41.      %        remainder
  42.  ----------------------------------------------------------------------------
  43.      +        add                                           left-to-right
  44.      -        subtract
  45.  ----------------------------------------------------------------------------
  46.     <<        bitwise left shift                            left-to-right
  47.     >>        bitwise right shift
  48.  ----------------------------------------------------------------------------
  49.      <        scalar less than                              left-to-right
  50.     <=        scalar less than or equal to
  51.      >        scalar greater than
  52.     >=        scalar greater than or equal to
  53.  ----------------------------------------------------------------------------
  54.     ==        scalar equal                                  left-to-right
  55.     !=        scalar not equal
  56.  ----------------------------------------------------------------------------
  57.      &        bitwise and                                   left-to-right
  58.  ----------------------------------------------------------------------------
  59.      ^        bitwise exclusive or                          left-to-right
  60.  ----------------------------------------------------------------------------
  61.      |        bitwise or                                    left-to-right
  62.  ----------------------------------------------------------------------------
  63.     &&        logical and                                   left-to-right
  64.  ----------------------------------------------------------------------------
  65.     ||        logical inclusive or                          left-to-right
  66.  ----------------------------------------------------------------------------
  67.    ?  :       conditional expression                        right-to-left
  68.  ----------------------------------------------------------------------------
  69.      =        assignment operator                           right-to-left
  70.               also   +=    -=    *=    /=    %=
  71.                      &=    ^=    |=   >>=   <<=
  72.  ----------------------------------------------------------------------------
  73.      ,        sequential expression                         left-to-right
  74.  ----------------------------------------------------------------------------
  75.  
  76. All of the operators in this table can be overloaded (C++) except:
  77.  
  78.           .     C++ direct component selector
  79.          .*     C++ dereference
  80.          ::     C++ scope access/resolution
  81.          ?:     Conditional
  82.