<object>不是<struct> </struct> </object>的成员

时间:2013-07-11 21:58:15

标签: c++ opencv struct namespaces

我对C ++有疑问。我正在使用OpenCV。我对两者都很陌生。

我有这个声明:

struct scoredRotatedRect
{
    double score;
    RotatedRect ellipse;
    vector<Point> contour;

};

问题在于,当我声明scoredRotatedRect时,它会将double识别为成员,而不将非原始类型识别为成员。

即,

cur_scoredRotatedRect.score=0; // not a problem
cur_scoredRotatedRect.ellipse=a_RotatedRect; // get an error

错误是

  

“'ellipse':不是'scoredRotatedRect'”的成员。

造成这种情况的原因是什么?

1 个答案:

答案 0 :(得分:0)

问题结果是我这样做了:

struct scoredRotatedRect
{
    double score;
    RotatedRect ellipse;
    vector<Point> contour;

};

using namespace std;
using namespace cv;

与此相反:

using namespace std;
using namespace cv;

struct scoredRotatedRect
{
    double score;
    RotatedRect ellipse;
    vector<Point> contour;

};

所以我猜最初的struct声明不知道RotatedRect指的是什么,只是忽略它(?)