向量:调整大小()与std:载体:Reserve()
std::vector::reserve()
std::vector::resize()
.
void MyClass::my_method(){ my_member.reserve(n_dim); for(int k = 0 ; k < n_dim ; k++ ) my_member[k] = k ;}
vector
std::vector::resize()
std::vector::reserve()
.
#include <vector>using namespace std;int main(){ vector<int> v; v.reserve(10); v[5] = 2; return 0;}
呼如林
相关分类