I have a function where I provide a pointer to a std::vector.
I want to make x = to vector[element] but i’m getting compiler errors.
I’m doing:
void Function(std::vector<int> *input)
{
int a;
a = *input[0];
}
What is the right way to do this?
Thanks
Should be:
Otherwise you’ve got
*(input[0]), which is*(input + 0), which is*input. Of course, why not just do:And if you don’t modify
input, mark it asconst: