Hello,
I get a compilation error with the following code but I do not
understand why this happens. Maybe somebody can explain, what the
compiler (GCC ) tries to do and why it fails.
-------[ CBoard.h ]--------
class CBoard {
...
map<string,CNode*> nodes;
...
};
--------8<-----------------
copy is called in the copy constructor and in the assignment operator.
It has to copy key=>value pairs from one map to another. CNode provides
a copy constructor, of course:
------[ CBoard.cpp ]-------
#include "CBoard.h"
....
// copy object
void
CBoard::copy(CBoard &other)
{
for (map<string,CNode*>::iterator i = nodes.begin();
i != nodes.end();
i++)
{
nodes[i->first] = CNode(*(i->second));
}
}
....
----[ compiler output ]----
CBoard.cpp: In member function `void CBoard::copy(CBoard&)':
CBoard.cpp:79: cannot convert `CNode' to `CNode*' in assignment
make: *** [board.o] Error 1
---------------------------
Regards,
Christof