Hey guys I have the following class code and i get an error in the addVertex method that says vertexList is not declared in scope but i dont know why.

#include <iostream>
#include "DirectGraph.h"
#include <string>
#include <list>
#include <vector>

DirectGraph::DirectGraph(): vertexList(100)
{
}
void DirectGraph::printShortestPath(int source)
{

}
void DirectGraph::addVertexEdge(int source, std::string end, std::string weight)
{
    std::list<std::string> edgeList;
    std::string strEdge = end + " " + weight;
    edgeList.push_front(strEdge);
    adjList[source] = edgeList;
}
void addVertex(int index, Vertex vert)
{
    vertexList.at(index) = vert;
}

this is the header file

#ifndef DIRECTGRAPH_H_INCLUDED
#define DIRECTGRAPH_H_INCLUDED
#include <list>
#include <string>
#include <vector>
#include <string>

struct Vertex
{
    std::list<std::string> adj;
    bool known;
    int dist;
    int vertNum;
    Vertex *path;
};
class DirectGraph
{
    public:
        DirectGraph();
        void printShortestPath(int source);
        void addVertexEdge(int source, std::string end, std::string weight);
        void addVertex(int index, Vertex vert);
    private:
        std::vector<std::list<std::string> > adjList;
        std::vector<Vertex> vertexList;
};

#endif // DIRECTGRAPH_H_INCLUDED

Any help is much appreciated

Recommended Answers

All 2 Replies

You forgot the DirectGraph:: .

You forgot the DirectGraph:: .

oh dear. i feel stupid. i guess crazy things happen when youre tired. thanks a bunch.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.