vector
constructor
std::vector<int> first;
std::vector<int> second(4, 100);
std::vector<int> third (second.begin(),second.end());
std::vector<int> fourth (third);
int myints[] = {16,2,77,29};
std::vector<int> fifth (myints, myints + sizeof(myints) / sizeof(int) );
std::vector<int> sixth = fifth;
std::vector<int> seventh = std::move(sixth); // 移动构造
常用操作
class A {
public:
A(int a) {}
};
std::vector<A> v;
v.push_back(A(1));
v.emplace_back(1); // 直接原地构造,节省一次拷贝开销
v.pop_back();
v.erase(v.begin());