void Nprint(vector<int>::const_iterator beg, vector<int>::const_iterator end)
{
while (beg != end)
{
cout << *beg++;
if (beg != end) cout << " ";
}
cout << endl;
}
int _tmain(int argc, _TCHAR* argv[])
{
/*int x = 5, y = 7;
int *pi = &x, *ip = &y;
ptrswap(pi, ip);
printf("%d%d", *pi,*ip);*/
int a[5] = { 0, 1, 2, 3, 4 };
vector<int> ave(a,a+5);
Nprint(ave.begin(),ave.end());
getchar();
return 0;
}
避免复制Vector,定义引用类型
最新推荐文章于 2023-03-01 10:15:43 发布