在下面的示例代码中,我需要将结构向量传递给函数。如何将结构向量传递给C++中的函数?
class A {
public:
struct mystruct {
mystruct (int _label, double _dist) : label(_label), dist(_dist) {}
int label;
double dist;
};
}
我声明如下矢量:
vector<A:: mystruct > mystry;
现在,在这个 “A” 级有如下的功能。
myfunc (vector<mystruct> &mystry);
如何将结构向量传递给我的“myfunc”?
@nommyravian这个问题是关于传递载体,在我的情况下,其结构的载体? – 2vision2 2013-04-08 04:40:38
这是关于矢量的东西。它们包含的内容并不重要。 – chris 2013-04-08 04:47:04
你在哪里遇到问题?将一个向量传递给一个函数就像将其他任何东西传递给一个函数一样。 – juanchopanza 2013-04-08 05:43:10