'&':对绑定成员函数表达式的非法操作。从KeyPoint矢量OpenCV获取容量

时间:2015-10-15 13:51:01

标签: c++ opencv

我的项目有问题,就像我在主题中写的那样。我希望从KeyPoint vector表获得容量。请告诉我,我的问题在哪里?

这是我的代码

class SidesOfFigure
{
public:
    SidesOfFigure() {
    };


    ~SidesOfFigure() {
    };

    //sideNumber == 0 => top
    //sideNumber == 1 => down
    //sideNumber == 2 => left
    //sideNumber == 3 => right
    void setSideOfFigure(vector <KeyPoint> keyPoints, int sideNumber) {
        sideOfFigure[sideNumber] = keyPoints;
    }
    uint64 getCapacityOfSide(int numberOfSide) {
        try
        {
            return sideOfFigure[numberOfSide].capacity;
        }
        catch (const std::exception&)
        {
            throw exception("Illegal number!");
        }
    }

private:
    vector <KeyPoint> sideOfFigure[4];
};

1 个答案:

答案 0 :(得分:2)

虽然错误消息本身相对奇怪,但问题是capacitystd::vector的成员函数,而不是成员变量。所以你只需要添加括号来调用它:sideOfFigure[numberOfSide].capacity()