首先。感谢大家的帮助!
这就是问题所在。尝试将列表的边之一设置为空
list[i].getAttachedNode(j) = 0;
这是错误。
Prj3.cpp:165:34: error: lvalue required as left operand of assignment
这是我的列表声明。
Node list[47];
这是附加节点的实现。
Node* Node::getAttachedNode(int direction) {return attachedNode[direction];}
[b]这是它所在的 block 。
for(int i = 0; i<48; i++)
{
for(int j = 0; j<6; j++)
{
string info = g.returnInfo(i,j);
switch(j)
{
case 0:
list[i].setNodeName(info);
break;
case 1:
if(info.compare(null) == 0)
{list[i].getAttachedNode(j) = 0;}
break;
}
}
}
最佳答案
错误很明显:
list[i].getAttachedNode(j)
是一个 r 值,因此不能分配给它。只需让 getAttachedNode
返回一个引用:
Node*& Node::getAttachedNode(int direction) {return attachedNode[direction];}
关于c++ - 将节点指针设置为空,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13316891/