我的项目有问题,就像我在主题中写的那样。我希望从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];
};
答案 0 :(得分:2)
虽然错误消息本身相对奇怪,但问题是capacity是std::vector
的成员函数,而不是成员变量。所以你只需要添加括号来调用它:sideOfFigure[numberOfSide].capacity()
。