1. auto
Firstly, auto can be used to automatically determin the types of values. However, when you use the keyword auto, you have to initialize the variables (i.e. you have to assign an initial value to the variables immediately after you define the variables).
EXAMPLE:
However, the example above is not appropriate since this kind of defining operate actually it not very clear. The keyword auto can be very helpful when you use it to replace some over complicated expression.
EXAMPLE:
Comparing the two outputing module, you can see how the keyword auto can help you coding.
Moreover, the keyword auto can also be helpful when we call templates. However, I don't know much about templates right now. I'll update this blog when I learn more about templates.
Useful links:
http://blog.csdn.net/huang_xw/article/details/8760403
http://blog.csdn.net/yhl_leo/article/details/50864612
http://www.cnblogs.com/QG-whz/p/4951177.html#_label2
http://en.cppreference.com/w/cpp/language/auto
2. vector
Vector is suppose to replace array in C. Vectors are able to store any types of data dynamically.
Be carefull:
1. avoid to define your vector too long.
2. usually, when you define a vector, the command goes: vector<type>name. However, if you want to define a vector as an input parameter, the command goes: int func( vector<type>&name)
vector operations:
1) you must include the head file <vector>;
2) create a vector object: vector<type> name;
3) insert element at the end of the vector: vec.push_back(element);
4) if you want to visit the ith element: vec[i], (remember the vector indexes starts from 0);
5) you can ues the iterator to visit elements in the vector:
vector<type>::iterator i;
for ( i = vec.begin(); i != vec.end(); i++) { cout<<*i<<endl;}
6) insert an element in the middle of the vector: vec.insert( vec.begin()+i,a);
7) delete an element: vec.erase(vec.begin()+i); this command deletes the (i+1)th element;
delet multiple elements: vec.erase(vec.begin()+i, vec.end()+j); this command deletes all the elements between vec[i] and vec[j];
8) size of the vector: vec.size();
9) clear the vector: vec.clear();
Useful links:
http://blog.csdn.net/duan19920101/article/details/50617190
http://www.cnblogs.com/wxmdevelop/p/4600762.html
http://blog.csdn.net/hancunai0017/article/details/7032383
http://blog.csdn.net/qq_15437667/article/details/52215917
3. uint8_t/uint16_t/uint32_t/uint64_t ......
Acctually, these data types are not new. They are only existed data types renamed using the keyword typedef.
int8_t corresponds to signed char
int16_t corresponds to short int
int32_t corresponds to int
int64_t corresponds to long int or long long int ( this part confuses me too....)
uint8_t corresponds to unsigned char
uint16_t corresponds to unsigned short int
uint32_t corresponds to unsigned int
uint64_t corresponds to unsigned long int or long long int (also confused)
Useful links:
http://blog.sina.com.cn/s/blog_9dcc0fb90101gdvo.html
http://blog.csdn.net/kiddy19850221/article/details/6655066