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

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

侯捷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 >;   //OK in each C++ version
vector>;    //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 v;
vector::iterator it = v.begin();
auto it = v.begin();
auto s = [](int x)->bool{    //s has the type of lambda
  .........,
};

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/zaji/5115428.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-11-17
下一篇 2022-11-17

发表评论

登录后才能评论

评论列表(0条)

保存