上一页 1 ··· 8 9 10 11 12 13 14 15 下一页
摘要: #include<vector> // 包含头文件vector ... using namespace std; // vector包含在std中,因此必须包含std::vector vector <int> vi; // create a zero-size array of int int n; 阅读全文
posted @ 2020-05-31 08:48 孱陵 阅读(584) 评论(0) 推荐(0) 编辑
摘要: #include < array > // 需要包含该头文件 ... using namespace std; // array位于std中 array < int, 5 > ai; // create array object of 5 ints array < double, 4 > ad = 阅读全文
posted @ 2020-05-31 08:22 孱陵 阅读(480) 评论(0) 推荐(0) 编辑
摘要: 优先级高的覆盖,同级发生冲突: using声明 = 自动变量 > using编译指令 = 全局 阅读全文
posted @ 2020-05-30 15:24 孱陵 阅读(336) 评论(0) 推荐(0) 编辑
摘要: auto h(int x, float y) -> double; // C++11后置返回类型 ->double被称为后置返回类型 auto是占位符(C++11新增用法) 结合decltype使用: template<class T1, class T2> auto gt(T1 x, T2 y) 阅读全文
posted @ 2020-05-30 13:49 孱陵 阅读(809) 评论(0) 推荐(0) 编辑
摘要: decltype (expression) var; // C++11 decltype是C++11新增的关键字 expression: 未用空号括起的标识符:var类型等于标识符类型 int a; decltype (a) var; // var type int 函数调用:var类型等于返回类型 阅读全文
posted @ 2020-05-30 10:46 孱陵 阅读(287) 评论(0) 推荐(0) 编辑
摘要: namespace // unnamed namespace { int ice; int bandicoot; } 该名称空间中声明的名称的潜在作用域为:从名称空间声明点到该声明区域末尾。(就好像后面紧跟着using编译指令) 注意: 不能在未命名名称空间所属文件之外的其它文件中使用该名称空间中的 阅读全文
posted @ 2020-05-29 19:45 孱陵 阅读(534) 评论(0) 推荐(0) 编辑
摘要: namespace my_very_favorite_things {...} namespace mvft = my_very_favorite_things; // mvft是my_very_favorite_things的别名 namespace MEF = myth::elements::f 阅读全文
posted @ 2020-05-29 15:22 孱陵 阅读(1331) 评论(0) 推荐(2) 编辑
摘要: namespace myth { using Jill::fetch; // using声明 using namespace elements; // using编译指令 using std::cout; // using声明 using std::cin; // using声明 ... } 名字空 阅读全文
posted @ 2020-05-29 15:09 孱陵 阅读(461) 评论(0) 推荐(0) 编辑
摘要: 声明时嵌套: namespace elements { namespace fire { int flame; ... } float water; } 使用内部名称空间: using namespace elements::fire; // 依此类推(第n层) 阅读全文
posted @ 2020-05-29 14:17 孱陵 阅读(609) 评论(0) 推荐(0) 编辑
摘要: 作用: 提供声明名称的区域 声明区域: 全局或位于另一名称空间中 空间中的名称链接性: 默认外部(常量除外)// 仅可在另一个文件的同一名称空间(必须写出所有的嵌套名称序列如果有的话)中使用extern声明这些名称(函数可不用extern),直接在另一个文件中常规用extern全局声明这些内部名称会 阅读全文
posted @ 2020-05-27 17:59 孱陵 阅读(226) 评论(0) 推荐(0) 编辑
上一页 1 ··· 8 9 10 11 12 13 14 15 下一页