【发布时间】:2016-02-13 13:25:18
【问题描述】:
我在尝试将对象引用添加到指针向量时遇到错误:
template <class Tpoint, class Tmodel> Tmodel ransac<Tpoint, Tmodel>::perform_fitting(const std::vector<Tpoint>& data){
std::vector<Tpoint*> also_inliers;
for (const auto& pnt : data){
if (fit_point(pnt, may_be_model) <= t){
also_inliers.push_back(&pnt); //error here
}
} // ! for range
}
来自 VS.NET 2013 的错误消息:
错误 88 错误 C2664: 'void std::vector>::push_back(cv::Point_ *const &)' : 无法将参数 1 从 'const cv::Point_ *' 转换为 'cv::Point_ *&&'
【问题讨论】:
-
您在
std::vector的声明中缺少const。应该是std::vector<Tpoint const*>。