常摘引了之后, 就不能取这个变量的地址了
常引用了之后, 就不能取这个变量的地址了?const COctree & o 是常引用作为参数吧,C/C++ codeCOctree* find
常引用了之后, 就不能取这个变量的地址了?
const COctree & o 是常引用作为参数吧,
C/C++ codeCOctree* findNode(Point_3 p, const COctree & o){ return o.FindVoxel(&o, p.x(), p.y(), p.z());// 取o的地址}
报错,说是: error C2662: 'COctree::FindVoxel' : cannot convert 'this' pointer from 'const COctree' to 'COctree &'
[解决办法]FindVoxel 不是一个const 函数. 而 o 是一个const 对象.所以出错.
不关取地址的事.
看EFFECTIVE C++ , 里面有说,函数能加const ,尽量加.
[解决办法]FindVoxel 这个函数声明要加 const
在 const 的对象上只能调用 const 的函数