窄化

#include <iostream>
#include <vector>
#include <string>
#include <queue>

using namespace std;;

void main(){
    vector<int> a1{1};
    queue<int> q1{1};

    //but

    int x1(2.1);//ok
    int x2 = 2.1;//ok

    //int x3{2.1};//error

    //but

    char x4{4};
    char x5{99999};//overflow

    //我想写的窄化  精度降低或造成数值变动
    //按sizeof()来讲的话。 x4 就是例外
}

猜你喜欢

转载自blog.csdn.net/qq_24328911/article/details/51405965