Должно быть:
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.
}
В противном случае вы получите *(input[0])
, что составляет *(input + 0)
, что составляет *input
.Конечно, почему бы просто не сделать:
void Function(std::vector<int>& input)
{
int a = input[0];
}
И если вы не измените input
, пометьте его как const
:
void Function(const std::vector<int>& input)
{
int a = input[0];
}