C++11 學習筆記-07.Spaces in Template Expressions

Spaces in Template Expressions

vector<list<int> >;   //可以在C++的版本,必須有空格
vector<list<int>>;//任何版本都可以這麼編譯通過了

nullptr and std::nullptr_t

C++11讓我們使用nullptr 代替0或者NULL

void f(int)
void f(void*)
f(0);//calls f(int)
f(NULL);//call f(int) 如果NULL是0,其他的就不知道了
f(nullptr);//calls f(void*)

\include\stddef

typedef deltype(nullptr) nullptr_t;

Automatic Type Deduction whit auto

auto i = 42;//i是int類型
double f()
auto d = f();//d是doublue類型
  • 好用的寫法
vector<string> v;
...
auto pos = v.begin();// pos 的類型是vector<string>::iterator

auto l =(int x)->bool{}; //l是一個lambad表達式
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章