1
我通过地图试图循环,并在其中值分配给要素指定值,以地图的成员通过迭代
manager.cpp:91:24: error: assignment of member ‘Node::online’ in read-only object iter->second.online = true;
这是我的节点结构:
#pragma once
#include <map>
#include "nodecon.h"
typedef map<int,int, less<int> >::const_iterator NodeNeighborsIter;
struct Node
{
int id;
std::map<int,int> neighbors;
bool online;
struct NodeConnection connection;
};
缺少什么我在这里?
对于其中之一,在尝试对其进行解引用之前,“iter”未分配给*任何*。 – WhozCraig
'const_iterator'表示它指向的对象是'const' - 不能改变。 –