Unhandled Exception Access Violation

96 Views Asked by At

I apologize for the lengthy code but I've been trying to spot the error and really cant find it. Has the error when i try to run it.

void setADist(vector<Facility> &vFac, vector<Client> &vClient, vector<Edge> &vEdge, vector<Node> &vNode){
            ...

            vector<Edge> temp(vEdge);
            float *distance;

            ...

            temp.push_back(Edge(101, 101, facEndNode, py(vFac[i].getLongitude(), x, vFac[i].getLatitude(), y)));

            Graphs *g1 = new Graphs();
            struct Graph* graph1 = g1->createGraph(temp.size());

            for (int k = 0; k < temp.size(); k++){
                //g1->addEdge(graph1, temp[k].getStartNode(), temp[k].getEndNode(), temp[k].getDist()); //THIS LINE CAUSES THE EXCEPTION
            }
            //g1->printGraph(graph1);
            //distance = g1->dijkstra(graph1, vFac[i].getNodeID());
        }

    }
}

}

The commented line causes the exception when i call the method.
I have tried running the following code below separately in main() and no exception was found so it cant be anything to do with the class Graphs.

Graphs *g = new Graphs();
struct Graph* graph = g->createGraph(vEdge.size());

for (int i = 0; i < vEdge.size(); i++){
    g->addEdge(graph, vEdge[i].getStartNode(), vEdge[i].getEndNode(), vEdge[i].getDist());
}
//g->printGraph(graph);

Really appreciate it if someone can provide me the solution.

0

There are 0 best solutions below