Page tree

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Published by Scroll Versions from space RWDEVEL and version 10.3.4

...

Table of Content Zone
maxLevel3
minLevel3
locationtop

Assignment

Assignment expressions include the following operators:

%=

Mod-equals operator. For example:

Code Block
int i = 2;
int j = 3;
j %= i; // Mod-equals operator "%="

&=

Bitwise-and-equals operator. For example:

Code Block
int i = 2;
int j = 3;
j &= i; // Bitwise-and-equals operator "&="

*=

Multiply-equals operator. For example:

Code Block
int i = 2;
int j = 3;
j *= i; // Multiply-equals operator "*="

++

Increment operator. For example:

Code Block
int i = 1;
i++; // increment operator "++"
++i; // increment operator "++"

+=

Plus-equals operator. For example:

Code Block
int i = 1;
int j = 0;
j += i; // Plus-equals operator "+="

--

Decrement operator. For example:

Code Block
int i = 10;
i--; // decrement operator "--"
--i; // decrement operator "--"

-=

Minus-equals operator. For example:

Code Block
int i = 1;
int j = 0;
j -= i; // Minus-equals operator "-="

/=

Divide-equals operator. For example:

Code Block
int i = 4;
int j = 2;
j /= i; // Divide-equals operator a/=b

<<=

Left-shift-equals operator. For example:

Code Block
int i = 2;
int j = 3;
j <<= i; // Left-shift-equals operator "<<="

=

Assignment operator. For example:

Code Block
int i = 1; // assignment operator "="
int j = 0; // assignment operator "="
j = i; // assignment operator "="

>>=

Right-shift-equals operator. For example:

Code Block
int i = 2;
int j = 3;
j >>= i; // Right-shift-equals operator >>=

^=

Bitwise-xor-equals operator. For example:

Code Block
int i = 2;
int j = 3;
j ^= i; // Bitwise-xor-equals operator "^="

|=

Bitwise-or-equals operator. For example:

Code Block
int i = 2;
int j = 3;
j |= i; // Bitwise-or-equals operator "|="

Bitwise

The following bitwise operators are included:

&

Bitwise 'AND' operator. For example:

Code Block
int z = 73, y = 0;
y = z & 0x0f; // Bitwise 'AND' operator "&"

^

Bitwise 'XOR' operator. For example:

Code Block
int z = 73, y = 0;
y = z ^ 0x0f; // Bitwise 'XOR' operator "^"

|

Bitwise 'OR' operator. For example:

Code Block
int x = 73, y = 0;
y = x | 4; // Bitwise 'OR' operator "|"

~

Bitwise 'NOT' operator. For example:

Code Block
int a = ~3; // Bitwise 'NOT' operator "~"

Comparison

The following comparison operators are included:

!=

'Not-equal' operator. For example:

Code Block
bool func(int x) {
 if (x!=3) { // 'Not-equal' operator "!="
 return false;
 }
 return true;
}

<

'Less than' operator. For example:

Code Block
bool func(int x) {
 if (x<3) { // 'Less than' operator "<"
 return false;
 }
 return true;
}

<=

'Less than or equals' operator. For example:

Code Block
bool func(int x) {
 if (x<=3) { 
 // 'Less than or equals' operator "<="
 return false;
 }
 return true;
}

==

'Equality' operator. For example:

Code Block
bool func(int x) {
 if (x==3) { // 'Equality' operator "=="
 return false;
 }
 return true;
}

>

'Greater than' operator. For example:

Code Block
bool func(int x) {
 if (x > 3) { // 'Greater than' operator ">"
 return false;
 }
 return true;
}

>=

'Greater than or equals' operator. For example:

Code Block
bool func(int x) {
 if (x >= 3) { // 'Greater than or equals' operator ">="
 return false;
 }
 return true;
}

Logical

The following logical operator expressions are included:

!

Logical 'NOT' operator. For example:

Code Block
bool func(int x) {
 if (!x) { 
 // Logical 'NOT' operator "!"
 return false;
 }
 return true;
}

&&

Logical 'AND' operator. For example:

Code Block
bool func(int x, int y) {
 if (x && y) { // Logical 'AND' operator "&&"
 return false;
 }
 return true;
}

||

Logical 'OR' expression. For example:

Code Block
bool func(int x, int y) {
 if (x || y) { // Logical 'OR' expression "||"
 return false;
 }
 return true;
}

Miscellaneous

The following miscellaneous expressions are included:

->

Dereference operator. For example:

Code Block
class A {
public:
 int field;
};
 
main() {
 A *a = new A;
 a->field = 1; // Dereference operator "->"
}


->* 

Arrow-star operator. For example:

Code Block
class Foo {
public:
 void func();
};
typedef void(Foo::*mpf)();
void bar(Foo *f) {
 mpf ampf = &Foo::func;
 (f->*ampf)(); // Arrow-star operator "->*"
}

.

Dot operator. For example:

Code Block
class A {
public:
 int foo;
}

[...]

a.foo = 1; //Dot operator.

::

Double colon operator. For example:

Code Block
class A {
 int foo();
};

int A::foo() { // Double colon operator (A::foo())
 return 1;
}

?

Ternary operator. For example:

Code Block
bool func(int x) {
 return x ? true : false; // Ternary operator "?"
}


.*

Pointer-to-member operator. For example:

Code Block
class A {
public:
void foo();
};
typedef void (A::*PtrToMember)();
void bar(A& a, PtrToMember ptr) {
 (a.*ptr)(); // ".*" operator
}

...

Ellipsis. For example:

void foo(...); /* ellipsis */

Numerical

The following numerical expressions are included:

%

Mod operator. For example:

Code Block
int j = 11;
int i = j % 2; //Mod operator (j % 2)

*

Asterisk operator. For example:

Code Block
int plus1 = 2 * 2; 
 //Asterisk operator (multiplication)
int *plus2 = &plus1; 
 //Asterisk operator (pointer type)

+

Plus operator. For example:

Code Block
int j = 2;
int plus1 = 1 + j; //Plus operator (addition)
int plus2 = +1; //Plus operator (meaningless)

-

Minus operator. For example:

Code Block
int j = 2;
int minus1 = 1 - j; //Minus operator (substraction)
int minus2 = -1; //Minus operator (negation)

/

Division operator. For example:

Code Block
float f = 3;
float r = f / 2; //Division operator

<<

Binary shift-left operator. For example:

Code Block
int i = 2;
int j = i << 1; //shift-left operator (i << 1)

>>

Binary shift-right operator. For example:

Code Block
int i = 2;
int j = i >> 1; //shift-right operator (i >> 1)

...