vector做形参时的三种传参方式

    vector在做形参的时候传参的方式和普通的变量是一样的,要么传值、要么传引用、要么传指针。

现在分别定义三个以vector为形参的函数:

(1) fun1(vector <int> v);传值

(2) fun2(vector <int> &v);传引用

(3) fun3(vector <int> *v);传指针

对应的调用形式分别为:

(1) fun1(v);

(2) fun2(v);

(3) fun3(&v);

猜你喜欢

转载自www.cnblogs.com/buanxu/p/12791909.html