I'm learning data structures right now, and I've been trying to figure out this error for over an hour!
In my main, I call:
...
#include "Graph.hpp"
Graph* g = new Graph();
g->addVertex("vertex1");
...
and in my Graph.cpp I have:
...
#include "Graph.hpp"
Vertex * Graph::addVertex( string name ) {
...
}
...
In my Graph.hpp:
...
class Graph{
Vertex *addVertex(string);
...
}
I'm getting the error when I compile:
undefined reference to `Graph::addVertex(std::string)'
EDIT:
The makefile:
CC=g++
CXXFLAGS = -std=c++11 -O2 -g - Wall
LDFLAGS= -g
main: main.o
g++ -o main main.o
main.o: Edge.hpp Graph.hpp Vertex.hpp Graph.cpp