摘要:decltype gives the declared type of the expression that is passed to it. auto does the same thing as template type deduction. So, for example, if you
阅读全文
摘要:1.A vector is a class template, a string is class. 模板(template)本身不是函数/类,但是可以指导编译器生成函数/类,该过程叫做实例化(instantiation)。 //常用初始化方法 vector<T> V(n, val); vector
阅读全文
摘要:C++11中的值类型(value categories) 基本类型 表达式有两个属性: has identity. 能够确定某个表达式是否和另一个表达式指涉[refers to]同一个实体,例如,通过比较它们标识[identify]出来的函数或者对象的地址(直接或间接得到的)。 can be mov
阅读全文
摘要:1.变量名的作用域(the scope of name) 对象的生命周期(the lifetime of an object) 2.各源文件(.cpp)可以单独编译得到目标代码(.obj),所有目标代码链接得到可执行程序(.exe) 3.局部静态对象 local static objects 在通过
阅读全文
摘要:头文件<algorithm>中的算法。 不直接作用于容器,通过迭代器遍历容器元素。 算法不会改变底下容器的大小,可以改变容器中元素的值。 1.求和 int sum = accumulate(C.cbegin(), C.cend(), 0); // 第三个参数表示sum = 0开始,C for Con
阅读全文