新しいオブジェクトのインスタンスでさまざまなエラーが発生しています。C++ でプログラミングするのは初めてなので、何もわかりませんが、何が欠けているのか本当にわかりません。私のコードと関連するエラーの例をいくつか示します。
Edge newEdge;
newEdge = new Edge(vertex2, neighbors(vertex1)); // create a new edge without weight
発生したエラーは次のとおりです。
invalid conversion from `Edge*' to `int'
initializing argument 1 of `Edge::Edge(int, Edge*, unsigned int)'
そしてコンストラクタは
public: Edge(int nextVertex = 0, Edge* ptr = NULL, unsigned int weight = 1):nextVertex(nextVertex),
next(ptr),
weight(weight){};
他のクラスについても同様です。
PriorityQueue queue = new PriorityQueue();
エラー:
conversion from `PriorityQueue*' to non-scalar type `PriorityQueue' requested
コード:
VertexPriority aux;
エラー:
no matching function for call to `VertexPriority::VertexPriority()'
そして最後に
ShortestPath shortp = new ShortestPath(graph);
エラー:
conversion from `ShortestPath*' to non-scalar type `ShortestPath' requested
これはインスタンスであり、エラーは似ているため、以前のものに限定されていると思われる別のエラーがあります。コードは次のとおりです。
queue.insert(new VertexPriority(vertex1, 0));
エラーは次のとおりです。
no matching function for call to `PriorityQueue::insert(VertexPriority*)'
candidates are: void PriorityQueue::insert(VertexPriority)
オブジェクトのコンストラクタは
VertexPriority(int vertex, unsigned int priority):vertex(vertex),
priority(priority){};
メソッド insert は引数として頂点を取ります:void insert(VertexPriority vertex);
私のコードで何が欠けていますか?