迭代器中的非标准语法错误?(c++)
Non standard syntax error in iterator? (C++)
void PointCloud::Create(std::vector<std::vector<cv::Point3d>> threeDPointSpace){
std::vector<std::vector<cv::Point3d>>::iterator row;
std::vector<cv::Point3d>::iterator col;
for (row = threeDPointSpace.begin(); row != threeDPointSpace.end(); row++) {
for (col = row->begin(); col != row->end(); col++) {
cv::Point3d thisOne = col._Getcont; // error reported here
vertices.push_back(VertexFormat(glm::vec3(thisOne.x, thisOne.y, thisOne.z), glm::vec4(1.0, 0.0, 1.0, 1.0)));
totalData++;
}
}
}
错误信息读取:
严重性代码描述项目文件行错误C3867 'std::_Iterator_base12::_Getcont':非标准语法;使用'&'创建指向成员
的指针
这是什么意思?我该如何解决这个问题?我没有正确使用这个迭代器模式吗?我正在尝试访问这些元素
您试图使用函数std::vector<cv::Point3d>::iterator::_Getcont
而不调用它(()
)或使用语法地址(&
),这确实是非标准的。
cv::Point3d thisOne = col._Getcont();
然而,这个函数是来自Visual Studio的标准库实现的内部(主要线索是_
和cppreference.com的文档中没有提到RandomAccessIterator的公共接口);我不知道你为什么要用它。只要解引用迭代器,就像其他人一样:
const cv::Point3d& thisOne = *col;
由于col
是std::vector<cv::Point3d>::iterator
,您必须使用
Point3d
访问属性cv::Point3d thisOne = col->_Getcont;
如果这是一个方法,确保你调用了
方法cv::Point3d thisOne = col->_Getcont();
你不应该使用?
cv::Point3d thisOne = col->_Getcont;
或者if _Getcont是成员函数
cv::Point3d thisOne = col->_Getcont();
或
cv::Point3d thisOne = ( *col )._Getcont;
cv::Point3d thisOne = ( *col )._Getcont();
或者你可以直接写
cv::Point3d thisOne = *col;
,因为左对象的类型与表达式*col
的类型相同。
在这种情况下,函数可以写成
void PointCloud::Create(std::vector<std::vector<cv::Point3d>> threeDPointSpace)
{
for ( auto &row : threeDPointSpace )
{
for ( auto &thisOne : row )
{
vertices.push_back(VertexFormat(glm::vec3(thisOne.x, thisOne.y, thisOne.z), glm::vec4(1.0, 0.0, 1.0, 1.0)));
totalData++;
}
}
}
相关文章:
- 警告处理为错误这里有什么问题
- "error: no matching function for call to"构造函数错误
- boost::进程间消息队列引发错误
- C++,OpenCV,尝试显示图像时"OpenCV(4.3.0) Error: Assertion failed (size.width>0 && size.height>0)"此错误
- 有关插入适配器的错误。[错误]请求从 'back_insert_iterator<vector<>>' 类型转换为非标量类型
- QT在错误的班级中寻找空位
- vector.resize()中的分配错误
- 代码在main()中运行,但在函数中出现错误
- 释放错误后堆使用
- (C++)分析树以计算返回错误值的简单算术表达式
- Project Euler问题4的错误解决方案
- 我的字符计数代码计算错误.为什么
- 从"int*"强制转换为"unsigned int"会丢失精度错误
- 尝试导入pybind-opencv模块时出现libgtk错误
- CMake项目Boost库错误:Boost/config/compiler/gcc.hpp:165:10:致命错误:cs
- 在某些循环内使用vector.push_back时出现分段错误
- MSVC多行宏编译器错误
- 静态数据成员的问题-修复链接错误会导致编译器错误
- 为什么在运行时没有向我们提供有关分段错误的更多信息?
- 错误:未在此范围内声明'reverse'