![](https://img-blog.csdnimg.cn/20201014180756738.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
C++语法
雪是无声雨
在秃头的路上顶风行走中......
展开
-
C++11 2.0 ranged-base for
ranged-base for C++11的2.0版本中提供了一种访问容器的另一种形式: 代码说明: #include <iostream> #include <vector> using namespace std; int main(){ vector<int>vint; //ranged-base for //初始化容器 for (int ix = 0; ix < 10; ix++) { vint.push_back(ix); } //遍历原创 2021-03-18 22:28:28 · 276 阅读 · 0 评论 -
C++11 2.0 auto
auto 假如你不想写被创建对象的类型,或者你不知道等式返回值类型是什么,你可以使用auto关键字,让编译器自动确定变量类型。 代码示例: #include <iostream> #include <list> #include <string> using namespace std; int main(){ /* ///// list<string> c; ... list<string>::iterator ite; ite =原创 2021-03-18 22:19:31 · 75 阅读 · 0 评论 -
C++11 2.0 variadic templates
varivadic templates - 数量不定的模板参数 C++11 2.0版本中新增了几个功能。 我们在写模板的时候如果需要传多个参数(未提前定),我们可以使用varivadic templates模型。如下用示例说明: #include <iostream> using namespace std; //必须要有的重载函数版本 void print() { } //variadic templates(since C++11) //数量不定的模板参数 template <ty原创 2021-03-18 22:08:40 · 99 阅读 · 0 评论