- default constructor
- copy constructor
- initializing constructor
The first one is pretty simple:
- vector<int> x;
Nothing special.
The second one is also a famous type of constructor:
- vector<int> x;
- x.push_back(1);
- x.push_back(2);
- vector<int> y(x.begin(), x.end());
- REP(i, y.size())
- cout << y[i] << endl;
The last but not least is the initializing constructor. Literally you can initialize vectors at the same time as declaring them.
- vector<int> x(10, 0);
You're creating a vector whose value is composed of 10 zeros.
0 件のコメント:
コメントを投稿