将节点指针设置为null

时间:2012-11-09 22:23:16

标签: c++ linked-list nodes

首先。我很感激帮助人员!

这就是问题。请将列表边缘之一设置为null

list[i].getAttachedNode(j) = 0;

这是错误。

Prj3.cpp:165:34: error: lvalue required as left operand of assignment

这是我的清单。

Node list[47];

这是attachNode实现。

Node* Node::getAttachedNode(int direction) {return attachedNode[direction];}

[b]这是包含在其中的块。

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;
                }
        }
    }

1 个答案:

答案 0 :(得分:1)

错误很明显:

list[i].getAttachedNode(j) 

是一个r值,因此无法分配。只需让getAttachedNode返回引用:

Node*& Node::getAttachedNode(int direction) {return attachedNode[direction];}