Why use ampersand inside a C++ function? [duplicate]

  c++, pointers
void printVector(const std::vector<int> &n) 
{
    for (int j = 0; j < n.size(); j++ )
    {
        cout << "n[" << j << "] = " << n[j] << endl;
    }
}

Why use here &n here? If I use vector<int> n instead vector<int> &n both give me same result!

Source: Windows Questions C++

LEAVE A COMMENT