Skip to content Skip to navigation

OpenStax-CNX

You are here: Home » Content » Abbreviated Precedence Chart for C++ Operators

Navigation

Recently Viewed

This feature requires Javascript to be enabled.

Tags

(What is a tag?)

These tags come from the endorsement, affiliation, and other lenses that include this content.
 

Abbreviated Precedence Chart for C++ Operators

Module by: Kenneth Leroy Busbee. E-mail the author

Summary: An abbreviated precedence chart for C++ operators typically used in a modular structured programming fundamentals course.

Note: You are viewing an old version of this document. The latest version is available here.

An operator is a language-specific syntactical token (one or more symbols) that causes an action to be taken on one or more operands. The following item provides an abbreviated list of those C++ operators that are typically taught in a programming fundamentals course that teaches modular structured programming concepts.

Operators between a set of lines have the same precedence and associativity.

OPERATOR NAME             SYMBOL(S)   COMMENTS        ASSOCIATIVITY

===================================================================

function call             ()                          Left to Right

array index               []

-------------------------------------------------------------------

postfix increment         ++          unary           Right to Left

postfix decrement         --          unary

-------------------------------------------------------------------

dereference               *           unary           Right to Left

unary positive            +           unary

unary minus               -           unary

prefix increment          ++          unary

prefix decrement          --          unary

cast                      (type)      unary

sizeof                    sizeof      unary (compile time)

logical NOT               !           unary

-------------------------------------------------------------------

multiply                  *                           Left to Right

divide                    /

modulus                   %           remainder

-------------------------------------------------------------------

add                       +                           Left to Right

subtract                  -

-------------------------------------------------------------------

bitwise left shift        <<          for cout        Left to Right

bitwise right shift       >>          for cin

-------------------------------------------------------------------

less than                 <                           Left to Right

greater than              >

less than or equal to     <=

greater than or equal to  >=

-------------------------------------------------------------------

equality                  ==          equal to        Left to Right

non-equality              !=          not equal to

-------------------------------------------------------------------

logical AND               &&                          Left to Right

-------------------------------------------------------------------

logical OR                ||                          Left to Right

-------------------------------------------------------------------

conditional               ?   :       trinary         Left to Right

-------------------------------------------------------------------

assignment                =                           Right to Left

addition/assignment       +=

subtraction/assignment    -=

multiplication/assignment *=

division/assignment       /=

modulus/assignment        %=

-------------------------------------------------------------------

sequence (or comma)       ,                           Left to Right

-------------------------------------------------------------------

 

Content actions

Download module as:

Add module to:

My Favorites (?)

'My Favorites' is a special kind of lens which you can use to bookmark modules and collections. 'My Favorites' can only be seen by you, and collections saved in 'My Favorites' can remember the last module you were on. You need an account to use 'My Favorites'.

| A lens I own (?)

Definition of a lens

Lenses

A lens is a custom view of the content in the repository. You can think of it as a fancy kind of list that will let you see content through the eyes of organizations and people you trust.

What is in a lens?

Lens makers point to materials (modules and collections), creating a guide that includes their own comments and descriptive tags about the content.

Who can create a lens?

Any individual member, a community, or a respected organization.

What are tags? tag icon

Tags are descriptors added by lens makers to help label content, attaching a vocabulary that is meaningful in the context of the lens.

| External bookmarks