C++代码知识整理
💡 面向就业的C++代码知识整理
C++代码知识
For
for-each
for specific value
Reference (&)
Use Reference in Function Parameter
Iterator
The magical way to use trravelsal in STL (vector, map, list).
Forward & Backward
1 |
|
C++ 11
Emplace
why emplace function have a better efficiency
Emplace can just create the data at the suitable location. But insert need to create first and then move to the suitable.
Auto
Before c++11, auto exists but is useless.
On c++11, auto is used to infer data type. For example, if you have a very long data type name, you can use auto to replace it.
1 |
|
Data Structure
Map
hashmap
There is no standard hashmap before c++11. So c++11 adds hashmap into its standard library and names ‘unorder_map’
1 | # Initialization |