https://www.jb51.cc/csharp/1192560.html

编程之家收集整理的这篇文章主要介绍了C++ 11新特性有哪些编程之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

C++11新特性: 1、auto;2、nullptr;3、for;4、lambda表达式;5、override、final;6、右值引用;7、move构造函数;8、容器初始化。

https://s3-us-west-2.amazonaws.com/secure.notion-static.com/f40ceb2d-a181-480c-8fd5-2dbad2d0e005/0bbbf3fa8cea1d6cda501e9e81881a72.jpg

C++11新特性:

(1)auto

使用auto实现任意两个数的加法

https://s3-us-west-2.amazonaws.com/secure.notion-static.com/aa1d7222-52f4-4a92-8ecd-3376fc787120/19557645b50ab0d643567e248d4ee230.png

(2)nullptr空指针

https://s3-us-west-2.amazonaws.com/secure.notion-static.com/82bf537e-80ac-4ba2-b500-72907d14ac24/28867ffc718a9e27eebd30e3b854b7c2.png

(3)for容器遍历

https://s3-us-west-2.amazonaws.com/secure.notion-static.com/2afc8058-adbe-4889-adf9-e208ecc51316/a43fd81950c8857a54585ef41fe8d4af.png

(4)lambda表达式

使用lambda表达式统计字符串个数,以及大写字母个数

https://s3-us-west-2.amazonaws.com/secure.notion-static.com/7f33feb9-eb08-425d-88a2-142e9001691c/615d329ec7f15ebdf18bf381dd939a28.png

(5)override、final

override表示重写基类的虚函数

https://s3-us-west-2.amazonaws.com/secure.notion-static.com/d7893dad-fce0-4b4a-a9b6-e936b92e6800/30b8936de635f63eb7ddbd55f2c80d8e.png

(6)右值引用