Should be:
void Function(std::vector<int> *input)
{
// note: why split the initialization of a onto a new line?
int a = (*input)[0]; // this deferences the pointer (resulting in)
// a reference to a std::vector<int>), then
// calls operator[] on it, returning an int.
}
Otherwise you've got *(input[0])
, which is *(input + 0)
, which is *input
. Of course, why not just do:
void Function(std::vector<int>& input)
{
int a = input[0];
}
And if you don't modify input
, mark it as const
:
void Function(const std::vector<int>& input)
{
int a = input[0];
}