传递矢量<vector <point>&gt;通过引用</vector <point>

时间:2013-09-02 16:49:58

标签: c++ image opencv image-processing

在OpenCV中如何传递

vector<vector<Point> > v

参考一个函数。

我测试了这个并且不起作用:

vector<vector<Point> > &v

2 个答案:

答案 0 :(得分:4)

如果你的函数有参考,它的原型应该是这样的:

void func( vector<vector<Point> > &v );

然后你必须将你的向量传递给这个函数:

vector<vector<Point> > v;    // Create your object
func( v );                   // Pass it to your function

这里解释了通过引用传递参数的过程:http://www.learncpp.com/cpp-tutorial/73-passing-arguments-by-reference/

答案 1 :(得分:1)

声明函数以获取引用:

void f(vector<vector<Point> > &v);

并使用正确类型的对象调用它:

vector<vector<Point> > v;
f(v);

该函数将接收对该对象的引用。

相关问题