c++数据类型,关键字,优先级

来源:互联网 发布:网络潮州歌曲大全100首 编辑:程序博客网 时间:2024/05/16 10:01

C/C++基本数据类型

-----------------------------------------------------------------------------------------------------------------------------------------------------------

Type                                                                                      Size                                           数值范围

--------------------------------------------------------------------------------------------------------------------------------------------------------------

布尔型bool                                                                          1 byte                                            true  false

--------------------------------------------------------------------------------------------------------------------------------------------------------------

有符号短整型  short int/signed short int                        2byte                                           -32768~32767

-----------------------------------------------------------------------------------------------------------------------------------------------------------------

无符号短整型unsigned short int                                     2 byte                                          0~65535

-----------------------------------------------------------------------------------------------------------------------------------------------------------------

有符号整型int /signed int                                                  4 byte                                         -2147483648~2147483647

-----------------------------------------------------------------------------------------------------------------------------------------------------------------

无符号整型unsigned int                                                    4 byte                                          0~4294967295

-----------------------------------------------------------------------------------------------------------------------------------------------------------------

有符号长整型long int/signed long int                               4byte                                          -2147483648~2147483647

-----------------------------------------------------------------------------------------------------------------------------------------------------------------

无符号长整型unsigned long int                                         4 byte                                         0~4294967295

-----------------------------------------------------------------------------------------------------------------------------------------------------------------

有符号字符型char/signed char                                          1 byte                                          -128~127

-----------------------------------------------------------------------------------------------------------------------------------------------------------------

无符号字符型unsigned char                                               1 byte                                         0~255

-----------------------------------------------------------------------------------------------------------------------------------------------------------------

宽字符型wchar_t (unsigned short)                                    2byte                                          0~65535

-----------------------------------------------------------------------------------------------------------------------------------------------------------------

单精度浮点型float                                                                   4 byte                                       3.4E-38~3.4E+38

----------------------------------------------------------------------------------------------------------------------------------------------------------------

双精度浮点型double                                                              8 byte                                      1.7E-308~1.7E+308

----------------------------------------------------------------------------------------------------------------------------------------------------------------

long double                                                                            8byte                                       -3.4E4932~1.1E4932

----------------------------------------------------------------------------------------------------------------------------------------------------------------


c++关键字

---------------------------------------------------------------------------------------------------------------------------------------------------------

auto       break       case         char         const                 continue                   default                do

double        else         enum           extern         float             for            goto           if              int

long          register        return     short         signed        sizeof             static           struct           switch

typedef         union        unsigned          void        volatile          while       

-------------------------------------------------------------------------------------------------------------------------------------------------------------    

bool          catch       class    const_cast           delete         dynamic_cast           explicit          false         friend         inline      

mutable      namespace        new         operator         private           protected          public               reinterpret_cast         

static_cast            template        this         throw           true      

------------------------------------------------------------------------------------------------------------------------------------------------------------

try         typeid        typename         using        virtual            wchar_t   

--------------------------------------------------------------------------------------------------------------------------------------------------------------

asm     cdect      far          huge      interrupt           near          pascal              export          except      fastcall          saveregs          stdcall

seg        syscall             fortran         thread

---------------------------------------------------------------------------------------------------------------------------------------------------------------


c++操作符优先级

 

 

优先级

 

操作符

 

结合性

    

1

()括号 []数组下标访问  ->对象的指针访问成员  :: 作用域

右->左

    

2

! 逻辑取反   ~ 按位取反 +一元取正  -一元取负  ++ 前置自增 --前置自减  &取地址  *解引用 sizeof  new  delete

右->左

    

3

. *在对象上通过指向成员的指针访问成员  -> *指针上通过指向成员的指针访问成员

左->右

    

4

 *乘法  /除法  %取余数

左->右

    

5

+加法  -减法

左->右

    

6

<<按位左移  >>按位右移

左->右

    

7

<小于    <=小于或等于    >=大于或等于     >大于

左->右

    

8

==等于比较               != 不等于

左->右

    

9

&按位与

左->右

    

10

^按位异或

左->右

    

11

|按位或

左->右

    

12

&&逻辑与

左->右

    

13

||逻辑或

左->右

    

14

?: 条件运算符

右->左

    

15

=赋值      *=复合赋值操作符(乘法)         /=       +=           -=         |=复合赋值操作符(按位或)        <<=复合赋值操作符(按位左移)  >>=复合赋值操作符(按位右移)

右->左

    

16

, 逗号操作符

左->右

    
1 0
原创粉丝点击