请教c++有多少个运算符
请问c++有多少个运算符
有没有官方发布的个数?不是那种自己算出来的。百度居然搜不到
------解决思路----------------------
------解决思路----------------------
很遗憾标准没有单独列出运算符 (operator) 。
但是有如下一个列表(这不是运算符列表):
2.13 Operators and punctuators [lex.operators]
1 The lexical representation of C++ programs includes a number of preprocessing tokens which are used in
the syntax of the preprocessor or are converted into tokens for operators and punctuators:
preprocessing-op-or-punc: one of
Each preprocessing-op-or-punc is converted to a single token in translation phase 7 (2.2).
------解决思路----------------------
C++ Operator Precedence
有没有官方发布的个数?不是那种自己算出来的。百度居然搜不到
------解决思路----------------------
//C++ Operators
// Operators specify an evaluation to be performed on one of the following:
// One operand (unary operator)
// Two operands (binary operator)
// Three operands (ternary operator)
// The C++ language includes all C operators and adds several new operators.
// Table 1.1 lists the operators available in Microsoft C++.
// Operators follow a strict precedence which defines the evaluation order of
//expressions containing these operators. Operators associate with either the
//expression on their left or the expression on their right; this is called
//“associativity.” Operators in the same group have equal precedence and are
//evaluated left to right in an expression unless explicitly forced by a pair of
//parentheses, ( ).
// Table 1.1 shows the precedence and associativity of C++ operators
// (from highest to lowest precedence).
//
//Table 1.1 C++ Operator Precedence and Associativity
// The highest precedence level is at the top of the table.
//+------------------+-----------------------------------------+---------------+
//
------解决思路----------------------
Operator
------解决思路----------------------
Name or Meaning
------解决思路----------------------
Associativity
------解决思路----------------------
//+------------------+-----------------------------------------+---------------+
//
------解决思路----------------------
::
------解决思路----------------------
Scope resolution
------解决思路----------------------
None
------解决思路----------------------
//
------解决思路----------------------
::
------解决思路----------------------
Global
------解决思路----------------------
None
------解决思路----------------------
//
------解决思路----------------------
[ ]
------解决思路----------------------
Array subscript
------解决思路----------------------
Left to right
------解决思路----------------------
//
------解决思路----------------------
( )
------解决思路----------------------
Function call
------解决思路----------------------
Left to right
------解决思路----------------------
//
------解决思路----------------------
( )
------解决思路----------------------
Conversion
------解决思路----------------------
None
------解决思路----------------------
//
------解决思路----------------------
.
------解决思路----------------------
Member selection (object)
------解决思路----------------------
Left to right
------解决思路----------------------
//
------解决思路----------------------
->
------解决思路----------------------
Member selection (pointer)
------解决思路----------------------
Left to right
------解决思路----------------------
//
------解决思路----------------------
++
------解决思路----------------------
Postfix increment
------解决思路----------------------
None
------解决思路----------------------
//
------解决思路----------------------
--
------解决思路----------------------
Postfix decrement
------解决思路----------------------
None
------解决思路----------------------
//
------解决思路----------------------
new
------解决思路----------------------
Allocate object
------解决思路----------------------
None
------解决思路----------------------
//
------解决思路----------------------
delete
------解决思路----------------------
Deallocate object
------解决思路----------------------
None
------解决思路----------------------
//
------解决思路----------------------
delete[ ]
------解决思路----------------------
Deallocate object
------解决思路----------------------
None
------解决思路----------------------
//
------解决思路----------------------
++
------解决思路----------------------
Prefix increment
------解决思路----------------------
None
------解决思路----------------------
//
------解决思路----------------------
--
------解决思路----------------------
Prefix decrement
------解决思路----------------------
None
------解决思路----------------------
//
------解决思路----------------------
*
------解决思路----------------------
Dereference
------解决思路----------------------
None
------解决思路----------------------
//
------解决思路----------------------
&
------解决思路----------------------
Address-of
------解决思路----------------------
None
------解决思路----------------------
//
------解决思路----------------------
+
------解决思路----------------------
Unary plus
------解决思路----------------------
None
------解决思路----------------------
//
------解决思路----------------------
-
------解决思路----------------------
Arithmetic negation (unary)
------解决思路----------------------
None
------解决思路----------------------
//
------解决思路----------------------
!
------解决思路----------------------
Logical NOT
------解决思路----------------------
None
------解决思路----------------------
//
------解决思路----------------------
~
------解决思路----------------------
Bitwise complement
------解决思路----------------------
None
------解决思路----------------------
//
------解决思路----------------------
sizeof
------解决思路----------------------
Size of object
------解决思路----------------------
None
------解决思路----------------------
//
------解决思路----------------------
sizeof ( )
------解决思路----------------------
Size of type
------解决思路----------------------
None
------解决思路----------------------
//
------解决思路----------------------
typeid( )
------解决思路----------------------
type name
------解决思路----------------------
None
------解决思路----------------------
//
------解决思路----------------------
(type)
------解决思路----------------------
Type cast (conversion)
------解决思路----------------------
Right to left
------解决思路----------------------
//
------解决思路----------------------
const_cast
------解决思路----------------------
Type cast (conversion)
------解决思路----------------------
None
------解决思路----------------------
//
------解决思路----------------------
dynamic_cast
------解决思路----------------------
Type cast (conversion)
------解决思路----------------------
None
------解决思路----------------------
//
------解决思路----------------------
reinterpret_cast
------解决思路----------------------
Type cast (conversion)
------解决思路----------------------
None
------解决思路----------------------
//
------解决思路----------------------
static_cast
------解决思路----------------------
Type cast (conversion)
------解决思路----------------------
None
------解决思路----------------------
//
------解决思路----------------------
.*
------解决思路----------------------
Apply pointer to class member (objects)
------解决思路----------------------
Left to right
------解决思路----------------------
//
------解决思路----------------------
->*
------解决思路----------------------
Dereference pointer to class member
------解决思路----------------------
Left to right
------解决思路----------------------
//
------解决思路----------------------
*
------解决思路----------------------
Multiplication
------解决思路----------------------
Left to right
------解决思路----------------------
//
------解决思路----------------------
/
------解决思路----------------------
Division
------解决思路----------------------
Left to right
------解决思路----------------------
//
------解决思路----------------------
%
------解决思路----------------------
Remainder (modulus)
------解决思路----------------------
Left to right
------解决思路----------------------
//
------解决思路----------------------
+
------解决思路----------------------
Addition
------解决思路----------------------
Left to right
------解决思路----------------------
//
------解决思路----------------------
-
------解决思路----------------------
Subtraction
------解决思路----------------------
Left to right
------解决思路----------------------
//
------解决思路----------------------
<<
------解决思路----------------------
Left shift
------解决思路----------------------
Left to right
------解决思路----------------------
//
------解决思路----------------------
>>
------解决思路----------------------
Right shift
------解决思路----------------------
Left to right
------解决思路----------------------
//
------解决思路----------------------
<
------解决思路----------------------
Less than
------解决思路----------------------
Left to right
------解决思路----------------------
//
------解决思路----------------------
>
------解决思路----------------------
Greater than
------解决思路----------------------
Left to right
------解决思路----------------------
//
------解决思路----------------------
<=
------解决思路----------------------
Less than or equal to
------解决思路----------------------
Left to right
------解决思路----------------------
//
------解决思路----------------------
>=
------解决思路----------------------
Greater than or equal to
------解决思路----------------------
Left to right
------解决思路----------------------
//
------解决思路----------------------
==
------解决思路----------------------
Equality
------解决思路----------------------
Left to right
------解决思路----------------------
//
------解决思路----------------------
!=
------解决思路----------------------
Inequality
------解决思路----------------------
Left to right
------解决思路----------------------
//
------解决思路----------------------
&
------解决思路----------------------
Bitwise AND
------解决思路----------------------
Left to right
------解决思路----------------------
//
------解决思路----------------------
^
------解决思路----------------------
Bitwise exclusive OR
------解决思路----------------------
Left to right
------解决思路----------------------
//
------解决思路----------------------
------解决思路----------------------
------解决思路----------------------
Bitwise OR
------解决思路----------------------
Left to right
------解决思路----------------------
//
------解决思路----------------------
&&
------解决思路----------------------
Logical AND
------解决思路----------------------
Left to right
------解决思路----------------------
//
------解决思路----------------------
------解决思路----------------------
------解决思路----------------------
Logical OR
------解决思路----------------------
Left to right
------解决思路----------------------
//
------解决思路----------------------
e1?e2:e3
------解决思路----------------------
Conditional
------解决思路----------------------
Right to left
------解决思路----------------------
//
------解决思路----------------------
=
------解决思路----------------------
Assignment
------解决思路----------------------
Right to left
------解决思路----------------------
//
------解决思路----------------------
*=
------解决思路----------------------
Multiplication assignment
------解决思路----------------------
Right to left
------解决思路----------------------
//
------解决思路----------------------
/=
------解决思路----------------------
Division assignment
------解决思路----------------------
Right to left
------解决思路----------------------
//
------解决思路----------------------
%=
------解决思路----------------------
Modulus assignment
------解决思路----------------------
Right to left
------解决思路----------------------
//
------解决思路----------------------
+=
------解决思路----------------------
Addition assignment
------解决思路----------------------
Right to left
------解决思路----------------------
//
------解决思路----------------------
-=
------解决思路----------------------
Subtraction assignment
------解决思路----------------------
Right to left
------解决思路----------------------
//
------解决思路----------------------
<<=
------解决思路----------------------
Left-shift assignment
------解决思路----------------------
Right to left
------解决思路----------------------
//
------解决思路----------------------
>>=
------解决思路----------------------
Right-shift assignment
------解决思路----------------------
Right to left
------解决思路----------------------
//
------解决思路----------------------
&=
------解决思路----------------------
Bitwise AND assignment
------解决思路----------------------
Right to left
------解决思路----------------------
//
------解决思路----------------------
------解决思路----------------------
=
------解决思路----------------------
Bitwise inclusive OR assignment
------解决思路----------------------
Right to left
------解决思路----------------------
//
------解决思路----------------------
^=
------解决思路----------------------
Bitwise exclusive OR assignment
------解决思路----------------------
Right to left
------解决思路----------------------
//
------解决思路----------------------
,
------解决思路----------------------
Comma
------解决思路----------------------
Left to right
------解决思路----------------------
//+------------------+-----------------------------------------+---------------+
------解决思路----------------------
很遗憾标准没有单独列出运算符 (operator) 。
但是有如下一个列表(这不是运算符列表):
2.13 Operators and punctuators [lex.operators]
1 The lexical representation of C++ programs includes a number of preprocessing tokens which are used in
the syntax of the preprocessor or are converted into tokens for operators and punctuators:
preprocessing-op-or-punc: one of
{ } [ ] # ## ( )
<: :> <% %> %: %:%: ; : ...
new delete ? :: . .*
+ - * / % ˆ &
------解决思路----------------------
~
! = < > += -= *= /= %=
ˆ= &=
------解决思路----------------------
= << >> >>= <<= == !=
<= >= &&
------解决思路----------------------
++ -- , ->* ->
and and_eq bitand bitor compl not not_eq
or or_eq xor xor_eq
Each preprocessing-op-or-punc is converted to a single token in translation phase 7 (2.2).
------解决思路----------------------
C++ Operator Precedence