If i have a pointer to a vector what is the correct syntax to access an element of the vector?
As expected this obviously fails, but whats the correct syntax for accessing an element at a position inside a vector?
void myfunc(std::vector<std::string> *p)
my_str = p[i]->mystring;
Thanks for any help,
foo->bar is just shorthand for (*foo).bar. If p was a vector, you would either use p[i] or p.at(i) to reference. Since p is now a pointer, *p is a vector, so (*p)[i] or (*p).at(i). This last you could write as p->at(i).