本文首发于个人博客https://kezunlin.me/post/b83bc460/,欢迎阅读最新内容! cpp11 push_back and emplace_back Guide case1 #include <iostream> #include <vector> class A { public: A (int x_arg) : x (x_arg) { std::cout << "A (x_arg)\n"; } A () { x = 0;…
1.类型与变量相关 1.1.nullptr: 取代了NULL,专用于空指针 1.2.constexpr: 近似const, 可以修饰变量,也可以修饰函数, 修饰变量如: const int global = 100; int main () { int temp = 100: constexpr int a = 1; //right constexpr int b = global; //right constexpr int c = temp; //wrong } 既可以赋值字面常量也可以赋值…