I have std :: vector and I have to resize it with some default value. Here is the code:
static int Counter = 0; class Data { Data() { Counter++; std::cout << Counter << std::endl; } }; std::vector<Data> mArray; for (int i=0; i <= 200; ++i) { mArray.push_back(Data()); }
As I understand it, after inserting 200 elements, I can resize it using the resize function, which takes a new size and default value for each new element.
When I run this program, I see:
0 1 2 ... 199 200 Resizing 201
Why is there only 1 element after the change?
source share