Precedence | Operator | Description | Example | Associativity |
---|---|---|---|---|
1 | () [] -> . :: ++ -- |
Grouping operator Array access Member access from a pointer Member access from an object Scoping operator Post-increment Post-decrement |
(a + b) / 4; array[4] = 2; ptr->age = 34; obj.age = 34; Class::age = 2; for( i = 0; i < 10; i++ ) ... for( i = 10; i > 0; i-- ) ... |
left to right |
2 | ! ~ ++ -- - + * & (type) sizeof |
Logical negation Bitwise complement Pre-increment Pre-decrement Unary minus Unary plus Dereference Address of Cast to a given type Return size in bytes |
if( !done ) ... flags = ~flags; for( i = 0; i < 10; ++i ) ... for( i = 10; i > 0; --i ) ... int i = -1; int i = +1; data = *ptr; address = &obj; int i = (int) floatNum; int size = sizeof(floatNum); |
right to left |
3 | ->* .* |
Member pointer selector Member pointer selector |
ptr->*var = 24; obj.*var = 24; |
left to right |
4 | * / % |
Multiplication Division Modulus |
int i = 2 * 4; float f = 10 / 3; int rem = 4 % 3; |
left to right |
5 | + - |
Addition Subtraction |
int i = 2 + 3; int i = 5 - 1; |
left to right |
6 | << >> |
Bitwise shift left Bitwise shift right |
int flags = 33 << 1; int flags = 33 >> 1; |
left to right |
7 | < <= > >= |
Comparison less-than Comparison less-than-or-equal-to Comparison greater-than Comparison geater-than-or-equal-to |
if( i < 42 ) ... if( i <= 42 ) ... if( i > 42 ) ... if( i >= 42 ) ... |
left to right |
8 | == != |
Comparison equal-to Comparison not-equal-to |
if( i == 42 ) ... if( i != 42 ) ... |
left to right |
9 | & | Bitwise AND | flags = flags & 42; | left to right |
10 | ^ | Bitwise exclusive OR | flags = flags ^ 42; | left to right |
11 | | | Bitwise inclusive (normal) OR | flags = flags | 42; | left to right |
12 | && | Logical AND | if( conditionA && conditionB ) ... | left to right |
13 | || | Logical OR | if( conditionA || conditionB ) ... | left to right |
14 | ? : | Ternary conditional (if-then-else) | int i = (a > b) ? a : b; | right to left |
15 | = += -= *= /= %= &= ^= |= <<= >>= |
Assignment operator Increment and assign Decrement and assign Multiply and assign Divide and assign Modulo and assign Bitwise AND and assign Bitwise exclusive OR and assign Bitwise inclusive (normal) OR and assign 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; |
right to left |
16 | , | Sequential evaluation operator | for( i = 0, j = 0; i < 10; i++, j++ ) ... | left to right |
杞細http://www.shnenglu.com/benbendy/archive/2008/05/23/50830.html
杞? http://hi.baidu.com/gwabit/blog/item/7a188726f2dc91178a82a1b6.html
C++/OPP/OOD緋誨垪:
灞傜駭涓錛氳娉?璇剰(C++)
1.1 [Lippman2000] Essential C++
Essential C++,by Stanley B. Lippman Addison Wesley Longman
2000,276 pages
Essential C++ 涓枃鐗?nbsp;錛屼警淇婃澃 璇戯紝282欏?nbsp;
1.2 [Gregory95] C++:The Core Language
C++:The Core Language by Gregory Satir 1995 O'Reilly
C++璇█鏍稿績錛屽紶閾辰銆璇?nbsp;錛?36欏?/p>
1.3 [Deitel98] The Complete C++ Training Course
The Complete C++ Training Course 2/e by Harvey M.Deitel 1998
Prentice Hall
C++澶у鏁欑▼(絎簩鐗?錛岄偙浠叉綐絳夈璇戯紝816欏?/p>
1.4 [Stevens2000] Standard C++ Bible
Standard C++ Bible 2000 Al Stevens IDG
鏍囧噯C++瀹濆吀錛屾灄涓介椊絳?nbsp;璇戯紝766欏?/p>
1.5 [Eckel2000] Thinking in C++
Thinking in C++ 2/e Bruce Eckel 2000 1470 pages Prentice
Hall
C++ 緙栫▼鎬濇兂錛屽垬瀹楃敯絳?nbsp;璇戯紝420欏?/p>
1.6 [Lippman98] C++Primer
C++ Primer,3rd Editoin,by Stanley Lippman and Josee Lajoie
Addison Wesley Longman,1998 1237 pages
C++ Primer 涓枃鐗堬紝渚繆鏉?nbsp;璇戯紝1999錛?237欏?/p>
1.7 [Struostrup2000] The C++ Programming Language
The C++ Programming Language,Special Editoin,by Bjarne
Stroustrup
Addison Wesley Longman,2000,1017 pages
C++紼嬪簭璇█緇忓吀鏈紝鍙剁鍝?nbsp;璇戯紝鍎掓灄 1999
1.7 [ANSI C++] C++瑙勬牸涔?nbsp;1998.9.1 PDF鏍煎紡
ANSI C++ 1996 Draft
灞傜駭浜岋細涓撳緇忛獙(C++/OOP)
2.1 [Meyers96] More Effective C++
More Effective C++,by Scott Meyers,Addison Wesley,1996,318pages
More Effective C++涓枃鐗堬紝渚繆鏉幫紝鍩圭敓 2000. 318欏?/p>
2.2 [Meyers98] Effective C++
Effective C++錛孲econd Edition,by Scott Meyers,Addison Wesley
Longman,1998.256pages
Effective C++ 2/e 涓枃鐗?渚繆鏉?鍩圭敓 2000.256欏?/p>
2.3 [Sutter99] Exceptional C++
Exceptional C++錛宐y Herb Sutter,Addison Wesley
Longman,2000.208pages
Exceptional C++涓枃鐗堬紝渚繆鏉?鍩圭敓 2000.248欏?/p>
2.4 [Sutter2001]More Exceptional C++
More Exceptional C++ by Herb Sutter,Addison Wesley
Longman,2001.
灞傜駭涓夛細搴曞眰鏈哄埗(C++ Object Model)
3.1 [Ellis90] The Annotated C++ Reference Manual
The Annotated C++ Reference Manual,by Margaret A.Ellis and
Bjarne Stroustrup
Addison Wesley Longman,1990,447 pages.
3.2 [Lippman96] Inside the C++ Object Model
Inside the C++ Object Model,by Stanley Lippman,Addison Wesley
Longman,1996,280pages
娣卞害鎺㈢儲C++鐗╀歡妯″瀷錛屼警淇婃澃 璇?nbsp;
灞傜駭鍥涳細璁捐瑙傚康鐨勫鐢?C++/Patterns)
4.1 [Gamma95] Design Patterns錛欵lements of Reusable Object Oriented
Software,
by Erich Gamma,Richard Helm,Ralph Johnson,and John
Vlissides,Addison Wesley,1995.395pages
璁捐妯″紡,鏉庤嫳鍐涚瓑璇?鏈烘宸ヤ笟鍑虹増紺?2000.254欏?/p>
4.2 [Alex2001]Modern C++ Design: Generic Programming and Design
Patterns Applied
by Andrei Alexandrescu,Addison-Wesley,2001,352Paper
Genericity/STL緋誨垪:
絎竴涓鐣屾槸浣跨敤STL:
[Josuttis99]:The C++ Standard Library 錛岮 Tutorial and
Reference,by Nicolai M.Josuttis,
Addison Wesley 1999.799pages
絎簩涓鐣屾槸浜嗚В娉涘瀷鎶鏈殑鍐呮兜涓嶴TL鐨勫鐞?
[Austern98]:Generic Programming and the STL -Using and
Extending the C++ Standard
Template library,by Matthew H.Austern,Addison Wesley
1998.548page
絎笁涓鐣屾槸鎵╁厖STL:
[Stepanov2001]:C++ Standard Template Library by
P.J.Plauger,Alexander A.Stepanov,
Meng Lee,David R.Musser,Prentice Hall 2001
榪欎簺灝辨槸浣犲簲璇ョ湅鐨勪功錛屽鏋滀綘鎯蟲垚涓洪珮鎵嬨?/p>