Copying Array to Vector Question
Hi,
A while ago, someone showed me how to copy an array of type char* into a vector. However I still don't really understand how it works.
Code:
const char *namesarray[3] =
{"Arnold",
"Barry",
"Colin"};
vector<string> namesvector(namesarray, namesarray+3);
I apologise if this is a stupid question, but why, when you're declaring the namesvector, do you need to put namesarray+3 in there? The vector is 3 elements long isn't it? So how come it's namesarray+3 and not just 3?
Thanks.