Jump to content

Operators in C and C++

From Wikipedia, the free encyclopedia

This is an old revision of this page, as edited by Kenny Moens (talk | contribs) at 15:34, 9 May 2004 (Added bitwise operators). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.

Arithmetic Operators

Operator Name Syntax Is overloadable? In C99?
Addition Operator a + b Yes. Yes.
Addition Prefix Operator ++a Yes. Yes.
Addition Postfix Operator a++ Yes. Yes.
Addition Assignment Operator a += b Yes. Yes.
Subtraction Operator a - b Yes. Yes.
Subtraction Prefix Operator --a Yes. Yes.
Subtraction Postfix Operator a-- Yes. Yes.
Subtraction Assignment Operator a -= b Yes. Yes.
Multiplication Operator a * b Yes. Yes.
Multiplication Assignment Operator a *= b Yes. Yes.
Division Operator a / b Yes. Yes.
Division Assignment Operator a /= b Yes. Yes.
Integer Division Operator a \ b Yes. Yes.
Modulus Operator a % b Yes. Yes.
Modulus Assignment Operator a %= b Yes. ?

Comparison Operators

Operator Name Syntax Is overloadable? In C99?
Less Than Operator a < b Yes. Yes.
Less Than Or Equal To Operator a <= b Yes. Yes.
Greater Than Operator a > b Yes. Yes.
Greater Than Or Equal To Operator a >= b Yes. Yes.
Not Equal To Operator a != b Yes. Yes.
Equal To Operator a == b Yes. Yes.
Negation Operator !a Yes. ?

Bitwise Operators

Operator Name Syntax Is overloadable? In C99?
Bitwise Complement ~a Yes. ?
Bitwise And a & b Yes. ?
Bitwise And + Assignment a &= b Yes. ?
Bitwise Or b Yes. ?
Bitwise Or + Assignment = b Yes. ?
Bitwise Xor a ^ b Yes. ?

Other Operators

Operator Name Syntax Is overloadable? In C99?
Assignment Operator a = b Yes. Yes.
Function Call Operator a() Yes. Yes.
Array Operator a[] Yes. Yes.
Dereference Operator *a Yes. Yes.
Arrow Operator a-> Yes. Yes.
Cast Operator (type)a Yes. Yes.