1 using 的功能完全覆盖typedef
typedef unsigned int unio_t;
using unio_t = unsigned int;
2 auto 和 decltype都用于自动类型推导
3 原来的空是NULL c++11是nullptr
4 基于范围的for循环
for(auto num : nums)
5 右值引用
c++98中允许 int num = 10;
int &a = num;
int &b = 10; //这是错误的 c++中不允许右值引用,除非 const int &b = 10;
c++11中 int &&a = 10;
6 五序容器
unordered_map
unordered_multimap (允许有重复键值对)
unordered_set
unordered_multiset(允许有重复)
底层原理是哈希表,查找元素时间复杂度为O(1);
用法和功能和map一摸一样。
7 智能指针
shared_ptr, unique_ptr, weak_ptr, auto_ptr(auto_ptr已被c++11弃用);
8 四种类型转换
const_cast: 将const变量转为非const
static_cast: 非const转const
dynamic_cast: 只能用于含有虚函数的类转换,用于类向上或向下转换。
reinterpret_cast:可以做任何类型的转换,但是不保证转换结果。