加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

c++新特性-收缩转换,二进制,constexpr,以及namespace&&amp

发布时间:2020-12-16 10:47:30 所属栏目:百科 来源:网络整理
导读:char(112312312);//不会检查是否超过范围,会截断 char{12345435345};//会报异常,异常如下: error C2397: 从“__int64”转换到“char”需要收缩转换 ?warning C4305: “初始化”: 从“__int64”到“char”截断 warning C4309: “初始化”: 截断常量值 ? c+

char(112312312);//不会检查是否超过范围,会截断

char{12345435345};//会报异常,异常如下:

error C2397: 从“__int64”转换到“char”需要收缩转换
?warning C4305: “初始化”: 从“__int64”到“char”截断
warning C4309: “初始化”: 截断常量值

?

c++14二进制支持(0b) 即int a=0b1001;//9,0B1101(13)

constexpr标志返回值或其他表达式是常量,用于返回常量可以用于需要常量表达式的等数组中

constexpr int get()

{

  return 100;

}

int?a[10+get()];//可以

inline 在命名空间新特性:namespace&& inline

#include <algorithm>
#include <iostream>
#include <functional>
#include <vector>
#include <numeric>
#include <array>
#include <cstring>
#include <cstdio>
using namespace  std;
namespace all{
    namespace V2017
    {
        void fun(int num){ cout << "int V2017" << endl; }

    }
}
namespace all {
    //展开在all,默认调用
    inline namespace V2018
    {
        void fun(int num){ cout << "int V2018" << endl; }
        void fun(double num){ cout << "double V2018" << endl; }

    }
}
int main()
{
    all::V2017::fun(12);//明确调用
    all::V2018::fun(16);
    all:fun(1);//默认调用
    system("pause");

}

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读