I have a general wondering about std::vector<string>.

If you declare something like this, I have set 1 million elements to this vector.
If I run this program just declare it like this without filling the elements with any strings.
Does this take up any RAM memory just because I have declared this number of elements or do I have to fill them up to take up RAM.

Then I do wonder how many MB is 1000000 (1 million elements) ?

std::vector<string> vec(1000000);

>>Does this take up any RAM memory just because I have declared this number of
>> elements
Yes -- it will take up (1000000 * sizeof(string)) + sizeof(vector) before any of the strings have been initialized with anything.

okay, then I know better how to think when I declare vectors. thank you.

>>Does this take up any RAM memory just because I have declared this number of
>> elements
Yes -- it will take up (1000000 * sizeof(string)) + sizeof(vector) before any of the strings have been initialized with anything.

This question has already been answered. Start a new discussion instead.