I have a problem with 2 member functions from which one is const returning a const:
const BoardNode & Board::getBoardNode(unsigned int rowIdx, unsigned int colIdx) const
{
return _mData[rowIdx*_mNumColumns + colIdx];
}
BoardNode & Board::getBoardNode(unsigned int rowIdx, unsigned int colIdx)
{
return _mData[rowIdx*_mNumColumns + colIdx];
}
After a while I use the code :
// where this is a Board holding Nodes in std::vector
BoardNode nodeToAddAsNeighbor = this->getBoardNode(x1+ x, y1+ y);
Whatever the values of y1, y, x, x1 are, I always return the node with coords (0,0).
Nevertheless other parameters of the node are different only the coords are as mentioned above.
Any idea why ?
EDIT
My copy contructor :
BoardNode::BoardNode(const BoardNode & other) :
_mNodeType(other._mNodeType),
_coordinates( other._coordinates ),
_neighboursVector( other._neighboursVector) {}
invokes the copy constructor. Is it defined? How is it defined? Perhaps it doesn’t work as advertised. E.g.
Obviously with
You can not expect b.i to contain 7, but rather it will contain 42