读C++Primer所得.2

    技术2025-12-02  5

     

    第二章

     

    1 整数的赋值

    当我们讲一个超出取值范围的数赋值给一个类型时,结果会怎么样?

    unsigned 的话直接取模. 负数也是.

    signed 基本类似.

     

    2. 字面值常量

    区别下面值:

    20

    024

    0x14

    128u

    14L

     

    3. 多行字面值

    处理长字符串

    std::cout << "Free /

        farm" << std::endl;

     

    4 变量名

    必须由下划线和字母开头, 例如:

    char _; 

    bool catch_22;

     

    5 const限定符

    引用别名:

    int ival = 1;

    int &ref = ival; //相当于换个名字

    只读形式: const int &read = ival ;

     

     

    最新回复(0)