У меня возникла ошибка в экземплярах новых объектов. Это первый раз, когда я программирую на 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
Существует в другую ошибку, что я думаю, что я ограничен в provious те, потому что это экземпляр и ошибка похожа, вот код:
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){};
и способ вставки имеет вершину для аргумента: void insert(VertexPriority vertex);
Что мне не хватает в моем коде?
Вы пропустили, что это не Java или C#. – WhozCraig