I’ve got another problem when trying to overload the () operator for array access:
const OctTreeNode*& operator()(const int i, const int j, const int k) const{
return m_cells[k*m_resSqr+j*m_res+i];
}
OctTreeNode*& operator()(const int i, const int j, const int k){
return m_cells[k*m_resSqr+j*m_res+i];
}
vector<OctTreeNode*> m_cells;
I get a
C2440 'return': cannot convert from 'OctTreeNode *const' to 'const OctTreeNode *&'
what’s the deal? i’m declaring it exactly as in another class. the only difference is that the other class is generic, and there i’m using T& instead of OctreeNode*&
The first operator should return const
… or the const before the
*, I never seem to remember -_-First const tells us that we can’t modify OctTreeNode, second one tells us that we can’t modify the pointer to it (set it to NULL for example) while the third one tells us that the method doesn’t change the object.
To be honest I’m unsure wether the first one is needed, as the only thing that we need to grant const correctness to the method, is to grant that nobody will change references to those pointers.