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

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>
            亚洲高清在线观看| 国产精品一区二区在线| 欧美激情偷拍| 一本色道久久综合亚洲精品不卡| 欧美精品久久久久久久久老牛影院 | 久久九九热免费视频| 美女任你摸久久| 亚洲人成在线播放网站岛国| 欧美日本一区二区三区| 一区二区精品国产| 久久久www| 亚洲人成网站精品片在线观看| 欧美日韩高清免费| 亚洲欧美一级二级三级| 美女主播视频一区| 这里只有精品在线播放| 国产欧美日韩一区二区三区在线| 欧美中文字幕在线视频| 亚洲国产91色在线| 亚洲综合激情| 亚洲国产精品www| 欧美视频久久| 久久久久一区二区| 夜夜爽av福利精品导航 | 欧美主播一区二区三区| 亚洲高清一区二| 香蕉免费一区二区三区在线观看| 伊人久久大香线蕉av超碰演员| 欧美丰满高潮xxxx喷水动漫| 亚洲欧美国产制服动漫| 欧美高清在线观看| 欧美一级播放| 亚洲精品中文字幕在线| 国产一区二区三区日韩| 欧美日韩综合另类| 久久久蜜桃精品| 亚洲一区二区三区在线看 | 欧美一区二区三区啪啪| 亚洲国产精品一区二区第四页av| 午夜影视日本亚洲欧洲精品| 亚洲精品美女91| 国产亚洲视频在线观看| 欧美香蕉视频| 欧美成人嫩草网站| 欧美在线综合| 亚洲欧美国内爽妇网| 日韩网站在线观看| 亚洲电影免费观看高清完整版| 久久精品国产一区二区三| 一本色道久久综合亚洲精品按摩| 亚洲国产成人不卡| 永久免费视频成人| 国产综合香蕉五月婷在线| 国产精品美女久久久| 欧美日韩亚洲一区二区三区四区| 六月婷婷一区| 久久综合成人精品亚洲另类欧美| 先锋影音网一区二区| 亚洲在线视频观看| 亚洲视频在线观看网站| 艳女tv在线观看国产一区| 亚洲国产日本| 亚洲国产精品悠悠久久琪琪| 欧美激情一区二区三级高清视频| 美腿丝袜亚洲色图| 久久综合色播五月| 久久综合电影一区| 久久综合影视| 欧美寡妇偷汉性猛交| 欧美激情a∨在线视频播放| 男女激情视频一区| 欧美激情2020午夜免费观看| 亚洲福利视频一区| 91久久精品国产91久久性色| 亚洲人成在线播放| 亚洲日韩第九十九页| 夜夜爽www精品| 亚洲一区二区日本| 欧美亚洲免费在线| 久久国产精品网站| 老司机免费视频久久| 欧美不卡视频一区| 欧美日韩高清在线观看| 欧美偷拍另类| 国产亚洲欧洲997久久综合| 一区二区视频免费完整版观看| 在线看片日韩| 一本色道久久综合亚洲精品不卡| 亚洲视频观看| 欧美专区日韩专区| 嫩草成人www欧美| 亚洲欧洲在线一区| 中文一区字幕| 欧美中文字幕| 欧美国产视频一区二区| 国产精品高潮久久| 狠狠操狠狠色综合网| 亚洲日韩成人| 欧美一区二区三区电影在线观看| 久久综合九色| 亚洲精品国产系列| 亚洲欧美中文在线视频| 久久综合精品国产一区二区三区| 欧美日本一区| 狠狠狠色丁香婷婷综合激情| 日韩视频在线观看| 久久av最新网址| 91久久精品国产91性色| 亚洲在线播放| 欧美精品aa| 狠狠色丁香婷综合久久| 亚洲美女啪啪| 久久躁日日躁aaaaxxxx| 99视频超级精品| 久久亚洲一区二区三区四区| 欧美午夜精品久久久| 亚洲国产精品小视频| 亚洲欧美日韩综合aⅴ视频| 欧美v日韩v国产v| 亚洲一区二区在线| 欧美国产日韩在线| 伊人春色精品| 欧美一区二区成人6969| 亚洲欧洲综合另类| 久久欧美中文字幕| 国产精品一区二区在线| 99一区二区| 欧美国产国产综合| 欧美影院成年免费版| 欧美视频三区在线播放| 亚洲全部视频| 男女精品网站| 欧美影院视频| 国产精自产拍久久久久久| 一区二区三区高清视频在线观看| 蜜臀va亚洲va欧美va天堂 | 国产综合一区二区| 亚洲在线观看免费视频| 91久久国产综合久久蜜月精品| 久久精品一区| 国产日产欧美一区| 亚洲欧美国产另类| 99视频超级精品| 欧美日韩精品三区| 日韩视频在线一区二区| 亚洲成人在线免费| 欧美国产综合视频| 欧美与黑人午夜性猛交久久久| 欧美午夜一区| 在线一区免费观看| 亚洲日本一区二区三区| 免费人成精品欧美精品| 国模精品一区二区三区色天香| 欧美主播一区二区三区| 亚洲天堂免费观看| 欧美性做爰猛烈叫床潮| 亚洲性感美女99在线| 日韩亚洲在线| 欧美午夜激情小视频| 亚洲午夜视频在线观看| 日韩亚洲国产欧美| 欧美视频一区二区三区在线观看 | 亚洲精品国产精品国自产观看| 久久影音先锋| 久久久精品免费视频| 国产自产2019最新不卡| 久久久7777| 久久都是精品| 亚洲第一福利视频| 欧美 日韩 国产一区二区在线视频| 久久久久一区| 亚洲国产精品传媒在线观看| 欧美大片一区二区| 欧美96在线丨欧| 日韩视频在线观看国产| 亚洲毛片在线看| 国产精品毛片a∨一区二区三区|国| 亚洲专区在线| 欧美影院久久久| 亚洲国产岛国毛片在线| 亚洲国产精品99久久久久久久久| 欧美成人视屏| 亚洲综合久久久久| 午夜影院日韩| 亚洲电影在线观看| 91久久久亚洲精品| 国产精品久久久久影院亚瑟| 久久精品人人做人人综合| 久久久久久91香蕉国产| 亚洲精品美女在线观看播放| 亚洲美女黄色片| 国产视频丨精品|在线观看| 免费观看30秒视频久久| 欧美极品一区| 性久久久久久久久| 久久一日本道色综合久久| av成人激情| 欧美影院在线| 一本久道久久综合中文字幕| 亚洲综合成人婷婷小说|