侯捷C++11课程笔记---第三次课

侯捷C++11课程笔记—第三次课

侯捷C++11课程笔记

第三课:Spaces in Template Expressions,nullptr and std::nullptr_t,Automatic Type Deduction with auto

1.Spaces in Template Expressions

vector<list<int> >;   //OK in each C++ version
vector<list<int>>;    //OK since C++11

2.nullptr and std::nullptr_t

C++11中针对空指针,我们用nullptr,之前是使用NULL或者0.

typedef decltype(nullptr) nullptr_t;

3.Automatic Type Deduction with auto

auto i = 42; //i has type int
double f();
auto d = f(); //d has type double

当type很长或者很复杂的时候我们用auto

vector<string> v;
vector<string>::iterator it = v.begin();
auto it = v.begin();
auto s = [](int x)->bool{    //s has the type of lambda
  .........,
};

猜你喜欢

转载自blog.csdn.net/qq_47997583/article/details/121181815
今日推荐