我有这个代码:
#include <iostream>
#include <vector>
#include <list>
using namespace std;
class Graph {
public:
//Create graph with n nodes
Graph(int size);
~Graph();
//Initialize graph
void InitializeGraphWithRandomNum();
private:
vector <list <int*> > *graph;
};
void Graph::InitializeGraphWithRandomNum() {
//Here I want to iterate
for (int i=0; i< graph->size(); i++) {
std::list <int*>::iterator it;
for (it = graph[i].begin(); it< graph[i].end();++it) {
..........
}
}
}
这里有问题。它说
'it = (((Graph*)this)->Graph::graph + ((unsigned int)(((unsigned int)i) * 12u)))->std::vector 中的 'operator=' 不匹配<_Tp, _Alloc>::以 _Tp = std::list, _Alloc = std::allocator >, std::vector<_Tp, _Alloc>::iterator = __gnu_cxx::__normal_iterator*, std::vector >,开头,类型名 std::_Vector_base<_Tp, _Alloc>::_Tp_alloc_type::pointer = std::list*' DejkstraAlg.cpp
谢谢 最好的