C++11 C++ primer 5th

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

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值