cannot convert `xyz' to `xyz*' in assignment

C

Christof Krueger

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,057
Latest member
KetoBeezACVGummies

Latest Threads

Top