0

首先。感谢各位的帮助!

这是问题。尝试将列表的边缘之一设置为空

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

1 回答 1

1

错误很明显:

list[i].getAttachedNode(j) 

是一个 r 值,因此不能分配给它。只需getAttachedNode返回一个参考:

Node*& Node::getAttachedNode(int direction) {return attachedNode[direction];}
于 2012-11-09T22:26:52.730 回答