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

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>
            免费久久精品视频| 亚洲韩国一区二区三区| 亚洲国产综合91精品麻豆| 欧美午夜电影完整版| 欧美一区二区三区在线| 欧美另类人妖| 亚洲国产福利在线| 激情视频一区二区| 亚洲欧美日韩人成在线播放| 99日韩精品| 欧美成人一品| 蜜桃av一区二区| 国内精品久久久久伊人av| 亚洲视频电影在线| 99re国产精品| 男女视频一区二区| 蘑菇福利视频一区播放| 国产一区二区三区直播精品电影| 日韩视频一区二区在线观看| 亚洲人体一区| 欧美精品久久99| 亚洲日本中文字幕| 日韩网站在线观看| 欧美精品高清视频| 亚洲精品乱码久久久久久久久 | 亚洲综合色在线| 欧美精品电影| 亚洲欧洲午夜| 亚洲深夜福利| 国产精品红桃| 亚洲综合视频在线| 欧美一区二区三区日韩视频| 国产精品一区二区久久久久| 亚洲一卡久久| 久久久久9999亚洲精品| 国产综合激情| 乱中年女人伦av一区二区| 欧美+亚洲+精品+三区| 在线国产精品播放| 欧美顶级大胆免费视频| 日韩一级大片在线| 欧美一区二区三区在线看 | 中国成人黄色视屏| 国产精品成人免费| 亚洲欧美另类在线观看| 久久一区亚洲| 日韩视频在线播放| 国产精品白丝jk黑袜喷水| 亚洲欧美在线aaa| 美国三级日本三级久久99| 亚洲国产精品国自产拍av秋霞| 欧美激情按摩| 亚洲欧美精品一区| 亚洲福利免费| 性久久久久久久久久久久| 黄色一区三区| 欧美日本亚洲视频| 先锋资源久久| 亚洲国产成人av在线| 亚洲午夜激情| 亚洲丰满少妇videoshd| 国产精品成人av性教育| 久久国产综合精品| 亚洲开发第一视频在线播放| 先锋影音一区二区三区| 91久久在线播放| 欧美三级黄美女| 久久综合狠狠综合久久综合88 | 一二美女精品欧洲| 久久人人看视频| 亚洲一区欧美| 91久久黄色| 国产欧美一区二区三区在线看蜜臀| 免费毛片一区二区三区久久久| 亚洲制服av| 亚洲破处大片| 欧美a级大片| 欧美在线观看一区二区| 日韩亚洲在线| 在线成人性视频| 国产精品视频免费一区| 欧美激情成人在线| 久久久久一本一区二区青青蜜月| avtt综合网| 亚洲国产中文字幕在线观看| 久久久久久久久久久久久久一区| 亚洲视频大全| 亚洲精品欧美极品| 精品1区2区| 黄色成人在线网址| 国产精品久久久久久久久免费樱桃| 久久一区免费| 久久久亚洲综合| 久久精品论坛| 欧美一区二视频在线免费观看| 99视频一区| 日韩午夜电影av| 亚洲精品久久久久| 91久久国产综合久久蜜月精品 | 欧美激情亚洲精品| 久久视频在线视频| 久久久91精品国产一区二区三区 | 国产私拍一区| 国产目拍亚洲精品99久久精品| 欧美日韩国产综合在线| 欧美精品电影| 欧美久久久久久久| 欧美日韩国产91| 欧美日韩国产丝袜另类| 美日韩精品视频| 免费在线成人av| 可以免费看不卡的av网站| 久久九九精品99国产精品| 欧美一区二区三区日韩| 欧美中文字幕在线观看| 欧美在线观看网站| 久久国产精品色婷婷| 久久久精品tv| 麻豆精品在线视频| 欧美福利在线观看| 欧美日韩国产色视频| 欧美日韩伊人| 国产日韩av在线播放| 黑人中文字幕一区二区三区| 尤物yw午夜国产精品视频| 亚洲电影一级黄| 日韩一级精品视频在线观看| 一区二区三欧美| 性久久久久久久| 久久久人成影片一区二区三区观看| 久久午夜电影| 亚洲欧洲另类| 亚洲天堂黄色| 久久久久久一区| 欧美激情精品| 国产精品一区二区你懂的| 国产亚洲激情视频在线| 在线观看精品视频| 一区二区不卡在线视频 午夜欧美不卡'| 99视频在线观看一区三区| 亚洲一区三区电影在线观看| 久久精品视频免费观看| 欧美激情国产日韩精品一区18| 亚洲精品自在久久| 亚洲欧美日韩综合aⅴ视频| 久久综合色88| 国产精品欧美激情| 亚洲欧洲精品一区二区三区波多野1战4 | 激情亚洲网站| 一区二区三区蜜桃网| 欧美在线免费一级片| 欧美丰满少妇xxxbbb| 99精品免费| 久久人人爽人人爽爽久久| 欧美日韩一区免费| 一区二区三区在线免费播放| 一本色道久久综合狠狠躁篇怎么玩| 欧美在线啊v一区| 亚洲成人在线视频播放| 亚洲一区二区三区国产| 欧美**人妖| 国产一区导航| 亚洲综合另类| 亚洲人成网站影音先锋播放| 欧美一区在线直播| 欧美色综合网| 亚洲精品日韩欧美| 久久久久久久综合色一本| 亚洲伦理在线免费看| 久久久噜久噜久久综合| 国产精品实拍| 亚洲一区在线观看免费观看电影高清| 免费91麻豆精品国产自产在线观看| 亚洲手机在线| 欧美日韩一区二区在线观看视频| 悠悠资源网久久精品| 久久精品一区二区三区中文字幕| 亚洲最快最全在线视频| 欧美v日韩v国产v| 激情91久久| 久久久国产一区二区| 亚洲欧美激情视频| 国产精品久久久久久av福利软件| 亚洲精品国偷自产在线99热| 美日韩在线观看| 欧美一乱一性一交一视频| 国产精品国产福利国产秒拍| 一本久道久久久| 亚洲国产精品999| 毛片基地黄久久久久久天堂| 在线播放日韩专区| 久久久噜噜噜| 久久久av水蜜桃| 亚洲福利国产| 久久福利电影| 欧美亚洲三区| 国产亚洲亚洲| 久久久亚洲欧洲日产国码αv| 亚洲图片欧洲图片av| 国产精品九色蝌蚪自拍|