03.12.2012 Views

C++ for Scientists - Technische Universität Dresden

C++ for Scientists - Technische Universität Dresden

C++ for Scientists - Technische Universität Dresden

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

30 CHAPTER 2. <strong>C++</strong> BASICS<br />

cast (type conversion) ( type ) expr<br />

member selection object.∗ pointer to member<br />

member selection pointer → ∗ pointer to member<br />

multiply expr ∗ expr<br />

divide expr / expr<br />

modulo (remainder) expr % expr<br />

add (plus) expr + expr<br />

subtract (minus) expr − expr<br />

shift left expr ≪ expr<br />

shift right expr ≫ expr<br />

less than expr < expr<br />

less than or equal expr expr<br />

greater than or equal expr >= expr<br />

equal expr == expr<br />

not equal expr != expr<br />

bitwise AND expr & expr<br />

bitwise exclusive OR (XOR) expr ˆ expr<br />

bitwise inclusive OR expr | expr<br />

logical AND expr && expr<br />

logical OR expr || expr<br />

conditional expression expr ? expr: expr<br />

simple assignemt lvalue = expr<br />

mulitply and assignemt lvalue ∗= expr<br />

divide and assignemt lvalue /= expr<br />

modulo and assignemt lvalue %= expr<br />

add and assignemt lvalue += expr<br />

subtract and assignemt lvalue −= expr<br />

shift left and assignemt lvalue ≪= expr<br />

shift right and assignemt lvalue ≫= expr<br />

AND and assignemt lvalue &= expr<br />

inclusive OR and assignemt lvalue |= expr<br />

exclusive OR and assignemt lvalue ˆ= expr<br />

throw exception throw expr<br />

comma (sequencing) expr , expr<br />

To see the operator precedences at one glance, use Table 2.13 on page 64. 8<br />

2.3.7 Overloading<br />

A very powerful aspect of C ++ is that the programmer can define operators <strong>for</strong> new types. This<br />

will be explained in section ??. Operators of built-in types cannot be changed. New operators<br />

cannot be added as in some other languages. If you redefine operators make sure that the<br />

expected priority of the operation corresponds to the operator precedence. For instance, you<br />

might have the idea using the L ATEX notation <strong>for</strong> exponentiation of matrices:<br />

8 TODO: Associativity?

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!