When I searching for resize function of the STL Vector, I find some of the words says that this function may change or delete some members in my vector or add some new members.
I just want to ask:
1.which member will be delete if the vector's size less than n?
2.what is the initialize value of the new members if I don't give the pramater "val"?
For question 1: If you resize down it removes what is at the end.
For question 2: Leaving out a value for "val" it will use the default value based on the vectors type. (0) zero for "int" types, (\0) for "char"s, (0.0) for floating point types and a std::string would be empty.
You might also be interested in the reserve() method, which reserves space for more items, but without actually constructing them. This is handy if your intention is to make room for a lot of items that you'll insert later. http://www.cplusplus.com/reference/vector/vector/reserve/