青青草原综合久久大伊人导航_色综合久久天天综合_日日噜噜夜夜狠狠久久丁香五月_热久久这里只有精品

woaidongmao

文章均收錄自他人博客,但不喜標題前加-[轉貼],因其丑陋,見諒!~
隨筆 - 1469, 文章 - 0, 評論 - 661, 引用 - 0
數據加載中……

C++算符優先級表

http://www.cppreference.com/wiki/operator_precedence

 

The operators at the top of this list are evaluated first. Operators within a group have the same precedence. All operators have left-to-right associativity unless otherwise noted.

 

Precedence

Operator

Description

Example

Overloadable

Associativity

1

::

Scope resolution operator

Class::age = 2;

no

left to right

2

()
()
[]
->
.
++
--
dynamic_cast
static_cast
reinterpret_cast
const_cast
typeid

Function call
Member initalization
Array access
Member access from a pointer
Member access from an object
Post-increment
Post-decrement
Runtime-checked type conversion
Unchecked type conversion
Reinterpreting type conversion
Cast away/Add constness
Get type information

isdigit('1')
c_tor(int x, int y) : _x(x), _y(y * 10) {}
array[4] = 2;
ptr->age = 34;
obj.age = 34;
for (int i = 0; i < 10; i++) cout << i;
for (int i = 10; i > 0; i--) cout << i;
Y& y = dynamic_cast<Y&>(x);
Y& y = static_cast<Y&>(x);
int const* p = reinterpret_cast<int const*>(0x1234);
int* q = const_cast<int*>(p);
std::type_info const& t = typeid(x);

yes
yes
yes
yes
no
yes
yes
no
no
no
no
no

left to right

3

!
not
~
compl
++
--
-
+
*
&
sizeof
new
new []
delete
delete []
(type)

Logical negation
Alternate spelling for !
Bitwise complement
Alternate spelling for ~
Pre-increment
Pre-decrement
Unary minus
Unary plus
Dereference
Address of
Size (of the type) of the operand in bytes
Dynamic memory allocation
Dynamic memory allocation of array
Deallocating the memory
Deallocating the memory of array
Cast to a given type

if (!done) …

flags = ~flags;

for (i = 0; i < 10; ++i) cout << i;
for (i = 10; i > 0; --i) cout << i;
int i = -1;
int i = +1;
int data = *intPtr;
int *intPtr = &data;
size_t s = sizeof(int);
long* pVar = new long;
long* array = new long[20];
delete pVar;
delete [] array;
int i = (int)floatNum;

yes

yes

yes
yes
yes
yes
yes
yes
no
yes
yes
yes
yes
yes

right to left

4

->*
.*

Member pointer selector
Member object selector

ptr->*var = 24;
obj.*var = 24;

yes
no

left to right

5

*
/
%

Multiplication
Division
Modulus

int i = 2 * 4;
float f = 10.0 / 3.0;
int rem = 4 % 3;

yes
yes
yes

left to right

6

+
-

Addition
Subtraction

int i = 2 + 3;
int i = 5 - 1;

yes
yes

left to right

7

<<
>>

Bitwise shift left
Bitwise shift right

int flags = 33 << 1;
int flags = 33 >> 1;

yes
yes

left to right

8

<
<=
>
>=

Comparison less-than
Comparison less-than-or-equal-to
Comparison greater-than
Comparison greater-than-or-equal-to

if (i < 42) …
if (i <= 42) ...
if (i > 42) …
if (i >= 42) ...

yes
yes
yes
yes

left to right

9

==
eq
!=
not_eq

Comparison equal-to
Alternate spelling for ==
Comparison not-equal-to
Alternate spelling for !=

if (i == 42) ...

if (i != 42) …

yes
-
yes

left to right

10

&
bitand

Bitwise AND
Alternate spelling for &

flags = flags & 42;

yes

left to right

11

^
xor

Bitwise exclusive OR (XOR)
Alternate spelling for ^

flags = flags ^ 42;

yes

left to right

12

|
bitor

Bitwise inclusive (normal) OR
Alternate spelling for |

flags = flags | 42;

yes

left to right

13

&&
and

Logical AND
Alternate spelling for &&

if (conditionA && conditionB) …

yes

left to right

14

||
or

Logical OR
Alternate spelling for ||

if (conditionA || conditionB) ...

yes

left to right

15

? :

Ternary conditional (if-then-else)

int i = a > b ? a : b;

no

right to left

16

=
+=
-=
*=
/=
%=
&=
and_eq
^=
xor_eq
|=
or_eq
<<=
>>=

Assignment operator
Increment and assign
Decrement and assign
Multiply and assign
Divide and assign
Modulo and assign
Bitwise AND and assign
Alternate spelling for &=
Bitwise exclusive or (XOR) and assign
Alternate spelling for ^=
Bitwise normal OR and assign
Alternate spelling for |=
Bitwise shift left and assign
Bitwise shift right and assign

int a = b;
a += 3;
b -= 4;
a *= 5;
a /= 2;
a %= 3;
flags &= new_flags;

flags ^= new_flags;

flags |= new_flags;

flags <<= 2;
flags >>= 2;

yes
yes
yes
yes
yes
yes
yes

yes

yes

yes
yes

right to left

17

throw

throw exception

throw EClass(“Message”);

no

 

18

,

Sequential evaluation operator

for (i = 0, j = 0; i < 10; i++, j++) …

yes

left to right

窗體頂端

窗體底端

Order of Evaluation and of Side Effects

One important aspect of C++ that is related to operator precedence, is the order of evaluation and the order of side effects in expressions. In most circumstances, the order in which things happen is not specified. For example in f() + g() whether f() or g() is called first is not specified. If at least one of the functions has side effects the results may differ across compilers, different versions of the same compiler or even between multiple runs of the same compiler.

Further, the effect of certain expressions is undefined. For example, consider the following code:

    float x = 1;

    x = x / ++x;

The value of x and the rest of the behaviour of the program after evaluating this expression is undefined. The program is semantically ill-formed: x is modified twice between two consecutive sequence points.

Expressions like the one above must be avoided. When in doubt, break a large expression into multiple statements to ensure that the order of evaluation is correct.

窗體頂端

窗體底端

Overloading of Operators

Overloading of operators can be very useful and very dangerous. On one hand overloading operators for a class you have created can help with logistics and readability of code. On the other hand you can overload an operator in such a way that it can either obfuscate or just downright break your program. Use carefully. In particular never overload &&, || or ,. In the overloaded context they lose the guarantee that the left operand is evaluated before the second and that there is a sequence point inbetween.

There are two ways to over load an operator: global function or class member.

Example of overloading with a global function:

     ostream& operator <<(ostream& os, const myClass& rhs);

But to be able to reach any private data within a user defined class you have to declare the global function as a friend within the definition of the class.

Example:

     class myClass {

 

       // Gives the operator << function access to 'myData'

       // (this declaration should not go in public, private or protected)

       friend ostream& operator <<(ostream& lhs, const myClass& rhs);

 

       private:

         int myData;

     }

Overloading with a class member can be done as follows:

     class myClass {

 

       public:

         // The left hand side of this operator becomes '*this'.

         int operator +(const myClass& rhs);

 

       private:

         int myData;

     }

 

posted on 2010-05-06 21:58 肥仔 閱讀(1082) 評論(0)  編輯 收藏 引用 所屬分類: C++ 基礎LEX & YACC

青青草原综合久久大伊人导航_色综合久久天天综合_日日噜噜夜夜狠狠久久丁香五月_热久久这里只有精品
  • <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
    <noscript id="pjuwb"></noscript>
          <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
            <dd id="pjuwb"></dd>
            <abbr id="pjuwb"></abbr>
            亚洲另类春色国产| 欧美日韩美女一区二区| 亚洲五月婷婷| 男女av一区三区二区色多| 欧美一区二区免费视频| 欧美日韩理论| 亚洲日本欧美| 亚洲国产成人精品视频| 久久精品人人做人人综合| 亚洲免费视频网站| 欧美午夜免费| 一区二区激情小说| 亚洲视频免费| 欧美日韩精品一区视频| 亚洲欧洲免费视频| 亚洲精品乱码久久久久久蜜桃麻豆| 久久久999精品免费| 久久午夜电影网| 国产一区二区精品久久99| 亚洲自拍电影| 欧美在线综合| 国产亚洲二区| 久久精品国产亚洲aⅴ| 久久国产婷婷国产香蕉| 国产亚洲女人久久久久毛片| 先锋影音国产精品| 欧美综合第一页| 国产亚洲激情视频在线| 欧美一区二区精品| 老色鬼久久亚洲一区二区 | 国产精品资源在线观看| 亚洲一区国产视频| 久久久久久亚洲精品不卡4k岛国| 国内激情久久| 美女被久久久| 99国产精品| 欧美一级在线亚洲天堂| 国产一区二区三区精品久久久| 久久久久网址| 亚洲激情在线播放| 亚洲午夜女主播在线直播| 国产精品一二三视频| 久久国产日本精品| 亚洲高清精品中出| 亚洲一区二区网站| 国产性猛交xxxx免费看久久| 免费短视频成人日韩| 亚洲每日更新| 久久精品视频播放| 亚洲日韩欧美视频| 国产精品久久久91| 久久久久久久久久久久久9999 | 亚洲国产va精品久久久不卡综合| aa日韩免费精品视频一| 国产精品青草久久久久福利99| 欧美专区一区二区三区| 亚洲国产日韩欧美综合久久 | 欧美在线一区二区| 亚洲国产精品va在线看黑人动漫| 欧美日本一区二区视频在线观看| 亚洲欧美精品伊人久久| 亚洲黄网站在线观看| 欧美一级夜夜爽| 亚洲精品免费网站| 国产亚洲成精品久久| 欧美日韩午夜精品| 久久亚洲私人国产精品va| 日韩一级大片| 欧美高清视频在线| 欧美在线不卡视频| 亚洲免费电影在线| 激情六月综合| 国产乱码精品一区二区三| 欧美精品国产一区| 久久久综合激的五月天| 亚洲欧美另类综合偷拍| 亚洲国产综合91精品麻豆| 久久精品视频在线| 亚洲影院高清在线| 亚洲美女在线看| 亚洲第一毛片| 激情久久久久久久| 国产欧美日韩视频一区二区| 欧美激情视频一区二区三区在线播放 | 亚洲精品免费网站| 免费观看在线综合| 久久成人羞羞网站| 亚洲欧美日韩电影| 一区二区欧美激情| 亚洲精品在线免费| 亚洲人成网站在线播| 狠狠色综合播放一区二区| 国产麻豆日韩欧美久久| 国产精品网站在线| 国产精品乱码| 国产精品入口福利| 欧美午夜精品| 国产精品扒开腿做爽爽爽视频| 欧美电影在线观看| 欧美成人免费在线视频| 蜜桃av综合| 噜噜噜噜噜久久久久久91| 久久综合九色综合欧美狠狠| 久久精品一区四区| 久久青草久久| 你懂的国产精品| 欧美激情精品久久久久久| 欧美大片免费观看在线观看网站推荐| 久久一区二区三区国产精品| 久久久亚洲高清| 美女黄毛**国产精品啪啪| 欧美a级理论片| 欧美成人资源网| 欧美激情视频一区二区三区免费 | 亚洲日韩第九十九页| 亚洲精品一区二区网址| 亚洲美女毛片| 亚洲一区二区三区视频| 欧美在线播放一区| 久久久噜噜噜久久中文字免 | 美女黄网久久| 欧美激情视频网站| 亚洲毛片在线观看| 亚洲欧美日韩天堂| 久久精品男女| 欧美+亚洲+精品+三区| 欧美日韩免费高清| 国产精品一二三| 国内精品久久久| 亚洲欧洲三级电影| 中文高清一区| 久久久久久国产精品mv| 欧美成人乱码一区二区三区| 亚洲人成网站999久久久综合| 亚洲视频免费在线| 久久久久天天天天| 欧美视频亚洲视频| 国产综合自拍| 日韩一级免费| 久久精品视频亚洲| 91久久久国产精品| 欧美亚洲免费电影| 欧美精品久久天天躁| 国产亚洲欧美一区二区三区| 亚洲免费观看高清在线观看| 欧美伊人影院| 亚洲人永久免费| 久久国产高清| 欧美亚一区二区| 在线免费高清一区二区三区| 一区二区三区日韩欧美| 久久久久九九九| 日韩一级网站| 蜜桃视频一区| 国产三级精品在线不卡| 亚洲少妇诱惑| 欧美激情在线免费观看| 亚洲欧美日韩天堂一区二区| 欧美精品在线一区二区| 影音欧美亚洲| 欧美在线综合视频| 国产精品99久久久久久宅男| 老司机aⅴ在线精品导航| 国产精品一区免费在线观看| 一区二区三区四区国产精品| 欧美成人精品一区| 欧美一区二区三区在线观看视频| 欧美日韩视频专区在线播放 | 久久精品视频在线播放| 国产精品成av人在线视午夜片| 亚洲国产一区二区视频| 久久欧美中文字幕| 亚洲综合色自拍一区| 欧美日韩一二三区| 99精品欧美一区二区三区综合在线 | 国产欧美日韩综合| 亚洲一区二区三区高清不卡| 亚洲国产精品一区在线观看不卡| 久久精品日韩| 激情欧美丁香| 久久久久网址| 欧美亚洲日本国产| 国产视频亚洲精品| 欧美在线观看日本一区| 亚洲视频日本| 国产精品蜜臀在线观看| 午夜久久资源| 亚洲网址在线| 国产精品免费小视频| 亚洲欧美在线另类| 亚洲深夜av| 国产精品日本一区二区| 欧美亚洲三区| 欧美一级免费视频| 国内精品久久久| 免费观看不卡av| 欧美韩国一区| 亚洲午夜一区二区三区| 亚洲深夜福利视频| 国产日韩精品一区二区浪潮av|