1. why null ptr
std::vector<Foo*> foos; // ... std::fill(foos.begin(), foos.end(), 0);
will compile error
in C++03 we can use
std::fill (foos.begin(), foos.edn(), static_cast<int *>(0));
this is why nullptr accepted.
2. extern template
3. initialization lists & uniform initialization
http://kalnitsky.org/2011/09/04/introduction-to-cpp11-part-2/en/
4. auto
http://kalnitsky.org/2011/08/28/introduction-to-cpp11-part-1/en/
With brining auto
into service the code readability increases considerably!You no longer have to write long and complicated template types. E.g. to getiterator:
// c++03
for (std::vector<std::map<int, std::string>>::const_iterator it = container.begin();
it != container.end();
++it)
{
// do something
}
// c++11
for (auto it = container.begin(); it != container.end(); ++it)
{
// do something
}
actually decltype
might be used to get the result offunctions, functors etc.
5. constexpr 编译器计算的常量表达式
6. string用+的时候不允许两边都是C-style string, 必须有一个是std::string
7. 114页,范围for 并且auto的时候,使用于多维数组时,除了最内层循环外,其他所有的外层循环的控制变量都要用引用类型
因为auto的时候数组会退化推断出指针。
--------------C++
8. 取模的模数只能是整数且不能是0
否则2%0报错Floating point exception
模数不能是浮点数。
9. 赋值运算符满足右结合律。
10. 移位运算不要用于有符号数
有符号数的右移是implemetation-defined.
http://blog.chinaunix.net/uid-23629988-id-3018793.html?page=2
11.顶层const无法重载函数,底层可以。 即是否指向常量 P208
12. C++中名字查找发生在类型检查之前。P210
13. 实参类型转换P219