请你回答一下STL里resize和reserve的区别
#include <iostream> #include <vector> int main(int argc, const char * argv[]) { // insert code here... std::vector<int> v({1,2,3,4,5}); v.reserve(2); std::cout<<v.size(); std::cout<<" "<<v.capacity(); std::cout<<"\n"; for(auto it:v) std::cout<<it<<" "; std::cout<<"\n"; v.resize(2); std::cout<<v.size(); std::cout<<" "<<v.capacity(); std::cout<<"\n"; for(auto it:v) std::cout<<it<<" "; }