【发布时间】:2017-07-14 11:12:18
【问题描述】:
例如,我用结构制作了一个数组:
#include <opencv2/opencv.hpp>
#include "utils/Configuration.h"
#include <time.h>
using namespace std;
using namespace cv;
struct plausibilitylinestruct{
int x0;
int y0;
int x1;
int y1;
float p;
} plausibilitylines[10];
如何在创建的数组上使用成员函数? C++ Refernce for array
我试过例如:
void addPlausibilitylines(vector<Vec4i> line) {
if(plausibilitylines.empty()) {
cout << "Test"<< endl;
}
}
编辑:我添加了更多代码
【问题讨论】:
-
你拥有的是一个原始的 C 数组。它没有任何成员函数。
-
plausibilitylines.empty()无效,因为plausibilitylines不是对象。您链接到的参考是std::array,您在这里没有使用。 -
您链接到的参考是 类模板
std::array。您定义的是一个简单的标准 C 样式数组。这两个是不同的。我建议你find some good beginners books阅读。
标签: c++ arrays struct member-functions