#include <iostream>
#include <vector>
using namespace std;
void fun(vector<int>&v, vector<int>&t)
{
v[2] = t[2];
}
int main()
{
vector <int> v = { 1,2,3,4,5 };
vector<int> t = { 6,7,8,9,10 };
fun(v, t);
cout << v[2];
system("pause");
return 0;
}
可直接作为数组调用,但是!如果要在函数中修改值,一定要加“&”!!!