ZONE
FEATURES
Home
News
Check Email
LEARNING ZONE
C++ Tutorial
Tutorials collection
Ask the Expert
FAQs
Refferences
ARTICLES
All articles
DOWNLOADS
Compilers
Sourcode Library
Tools/Utilities
WINDOWS
Win programing
C++ Builder
UNIX
Unix programming
Unix downloads
WEB PROGRAMMING
CGI programming
CGI Scripts
RESOURCES
Magazines
Newsletters
Mailing Lists
Courses
Links
COMMUNICATION
Message board
Chat
Communities
Organisations
C++ Groups
C++ Newsgroups
ABOUT US
Contact us
submit a resource
Privacy
Link to us
 
 
 
Home Ask the expert
 

Ask me a question

Main Q & A Page
 
SUBJECT : Operator precedence and associativity

What are the Operator precedence and associativity rules in C/C++

     
Sender : Dave  
 
Reply1

:: scope resolution (C++, e.g. name::member) left-to-right

:: global (C++, e.g. ::name)

( ) function call left-to-right

[ ] array element

. class, structure or union member

-> pointer reference to member

:: scope access / resolution (C++)

sizeof size of object in bytes

sizeof size of type in bytes

++ post increment (lvalue++) right-to-left

++ pre increment (++lvalue)

-- post decrement (lvalue--)

-- pre decrement (--lvalue)

~ bitwise complement

! logical not

- unary minus

+ unary plus

& address of

* contents of

new create object (C++)

delete destroy object (C++)

delete[] destroy array (C++)

(type) cast to type

.* member pointer (C++) left-to-right

->* pointer reference to member pointer (C++)

* multiply left-to-right

/ divide

% remainder

+ add left-to-right

- subtract

<< bitwise left shift left-to-right

>> bitwise right shift

< scalar less than left-to-right

<= scalar less than or equal to

> scalar greater than

>= scalar greater than or equal to

== scalar equal left-to-right

!= scalar not equal

& bitwise and left-to-right

^ bitwise exclusive or left-to-right

| bitwise or left-to-right

&& logical and left-to-right

|| logical inclusive or left-to-right

? : conditional expression right-to-left

= assignment operator right-to-left

also += -= *= /= %=

&= ^= |= >>= <<=

, sequential expression left-to-right

All of the operators in this table can be overloaded (C++) except:

. C++ direct component selector

.* C++ dereference

:: C++ scope access/resolution

?: Conditional

Sender : D.O  
 
 
 
 

Ask me a question

Main Q & A Page
 
 
A
Email Login
Password
New?
sign up!
 
A
Free Online tutorial & courses
 
A
Join Our Message board Discussions on C/C++
 
A
Unix Network
programming
tutorial
 
 Join Our Mailing list