- We can construct a vector to store a bunch of strings by writing vector, but a string is can be variable length, how can vector deal with that?
- I also test a demo, test[0] begin with 0x2508cb0, test[1] begin with 0x2508cb8, but the diff of two addresses and the capacity of test[0] seems to be not same.
int main() {
vector<string> test;
test.push_back("tes3235235et");
test.push_back("135125151241241241");
cout << test[0].capacity() << endl;
cout << test[1].capacity() << endl;
cout << &(test[0]) << endl;
cout << &(test[1]) << endl;
return 0;
}
Output:
12
18
0x2508cb0
0x2508cb8