c++新特性-收缩转换,二进制,constexpr,以及namespace&&
发布时间: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”需要收缩转换 ? 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"); } (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
相关内容
- Serializing XML DOMs using Xerces/Xalan
- Flex Url地址里的汉字转码问题
- ruby-on-rails – 如何将YAML放在YAML文档中
- ruby-on-rails – 为什么有这么多宝石砸了,你对依赖有什么作
- 从VB.NET调用存储过程
- 解决CRS-4639: Could not contact Oracle High Availabilit
- 使用PLSql连接Oracle时报错ORA-12541: TNS: 无监听程序
- 将dwr集成到spring mvc(dwr的配置是基于xml)
- mongodb-$type、limit、skip、sort方法、索引、聚合
- Ruby popen3和ANSI颜色