one array which saves some strings. when I check everyone address of string in array, i found that one string just take 8 bytes, look like array just save point to string but not string object. I want to known the reason.
my code as shown below:
#include <string>
#include <iostream>
using namespace std;
int main()
{
string nums[] = {"oneoneoneoneoneoneone",
"twotwotwotwotwotwotwotwotwo",
"threethreethreethreethreethreethreethreethreethreethree"};
for (int i = 0; i < 3; ++i) {
cout << &nums[i] << endl;
}
}
the result of this program show:
0x7ffe432ba6f0 0x7ffe432ba6f8 0x7ffe432ba700
address of the second item is bigger than first item 8 bytes.