对于下面的代码,我不断收到此错误。
在阅读此,我相信我的错误是it++在我的for循环,我试图与更换next(it, 1),但它并没有解决我的问题。
我的问题是,迭代器是给我问题的那个吗?
#include <iostream>
#include <vector>
#include <stack>
#include <set>
using namespace std;
struct Node
{
char vertex;
set<char> adjacent;
};
class Graph
{
public:
Graph() {};
~Graph() {};
void addEdge(char a, char b)
{
Node newV;
set<char> temp;
set<Node>::iterator n;
if (inGraph(a) && !inGraph(b)) {
for (it = nodes.begin(); it != nodes.end(); it++)
{
if (it->vertex == a)
{
temp = it->adjacent;
temp.insert(b);
newV.vertex = b;
nodes.insert(newV);
n = nodes.find(newV);
temp …Run Code Online (Sandbox Code Playgroud)