C++ 11新特性学习 - 笔记

1) enum class : 强类型枚举

2) 构造函数相互调用

3) final 与 override

4) 删除构造函数,关键字delete

5) const char* e R"(string e1 "\\stirng e2)"// raw string

6) lambda 捕获时机 ( [=], [&] )

int i = 1;
auto f = [=]() { std::cout << i << std::endl; };
i = 2;
f(); // 输出 1

 7) const int& ref = 10;  (it's ok)

 8) 左值引用与右值引用

  1. 左值引用, 使用 T&, 只能绑定左值
  2. 右值引用, 使用 T&&, 只能绑定右值 (Rvalue references can be used to extend the lifetimes of temporary objects )
  3. 常量左值, 使用 const T&, 既可以绑定左值又可以绑定右值
  4. 已命名的右值引用,编译器会认为是个左值
posted @ 2020-10-31 22:49  upupon  阅读(85)  评论(0编辑  收藏  举报