为何同一个类里面一处有错,另一处没有错?
时间:2011-12-05
来源:互联网
在local_from_world()这个函数里面, for(iter = shapes_.begin(); iter!= shapes_.end(); iter++)这一行出现错误:
error C2679: binary '=' : no operator found which takes a right-hand operand of type 'std::_Vector_const_iterator<_Ty,_Alloc>' (or there is no acceptable conversion)
但在render函数里面,同样这一行,却没错?
为啥?
代码如下
C/C++ code
error C2679: binary '=' : no operator found which takes a right-hand operand of type 'std::_Vector_const_iterator<_Ty,_Alloc>' (or there is no acceptable conversion)
但在render函数里面,同样这一行,却没错?
为啥?
代码如下
C/C++ code
Matrix3x3 CoordinateSystem::local_from_world() const { Matrix3x3 m; m.assignIdentity(); std::vector<Shape*>::iterator iter; for(iter = shapes_.begin(); iter!= shapes_.end(); iter++) { if ((*iter)->parent()!=NULL) { m=(*iter)->parent()->local_from_parent()*m; } } return m; } //在render函数里面却没有错? void CoordinateSystem::render() { // push and post multiply the OpenGL modelview matrix by a transformation that // maps this coordinate system's local space into its parent space. glMatrixMode(GL_MODELVIEW); glPushMatrix(); Matrix3x3 mmd=parent_from_local(); Matrix3x3 nnd=mmd.transpose(); GLdouble m[16]={*(nnd[0]),*(nnd[0]+1),0,*(nnd[0]+2),*(nnd[1]),*(nnd[1]+1),0,*(nnd[1]+2), 0,0,1,0, *(nnd[2]),*(nnd[2]+1),0,*(nnd[2]+2)}; glMultMatrixd(m); std::vector<Shape*>::iterator iter; for(iter = shapes_.begin(); iter!= shapes_.end(); iter++) { (*iter)->render(); } std::vector<CoordinateSystem*>::iterator CS_iter; for(CS_iter = children_.begin(); CS_iter != children_.end(); CS_iter++) { (*CS_iter)->render(); } glPopMatrix(); }
作者: superwavelet 发布时间: 2011-12-05
最好把shape贴出来看看!!!!!!!!!!
作者: neolyao 发布时间: 2011-12-05
这个错误显示的是迭代器类型(iterator)没有重载运算符“=”
即编译器不理解iter = shapes_.begin()该怎么赋值
至于为什么第二次出现没有问题
你将这两个函数的位置对调一下看看
如果还是同样的问题,也就是运算符重载的问题无疑了
即编译器不理解iter = shapes_.begin()该怎么赋值
至于为什么第二次出现没有问题
你将这两个函数的位置对调一下看看
如果还是同样的问题,也就是运算符重载的问题无疑了
作者: sxbwelcome 发布时间: 2011-12-05
相关阅读 更多
热门阅读
-
office 2019专业增强版最新2021版激活秘钥/序列号/激活码推荐 附激活工具
阅读:74
-
如何安装mysql8.0
阅读:31
-
Word快速设置标题样式步骤详解
阅读:28
-
20+道必知必会的Vue面试题(附答案解析)
阅读:37
-
HTML如何制作表单
阅读:22
-
百词斩可以改天数吗?当然可以,4个步骤轻松修改天数!
阅读:31
-
ET文件格式和XLS格式文件之间如何转化?
阅读:24
-
react和vue的区别及优缺点是什么
阅读:121
-
支付宝人脸识别如何关闭?
阅读:21
-
腾讯微云怎么修改照片或视频备份路径?
阅读:28