Working With Multiple Classes Which Are Dependent On Each Other- C++

  Kiến thức lập trình

duplicate symbol '__ZN6VertexC2Eci' in:
    /private/var/folders/vc/3kj9mnnj0kq7q9p65xwy02f40000gn/T/EDGE-8fc5e7.o
    /private/var/folders/vc/3kj9mnnj0kq7q9p65xwy02f40000gn/T/VERTEX-a123e4.o
duplicate symbol '__ZN6VertexC1Eci' in:
    /private/var/folders/vc/3kj9mnnj0kq7q9p65xwy02f40000gn/T/EDGE-8fc5e7.o
    /private/var/folders/vc/3kj9mnnj0kq7q9p65xwy02f40000gn/T/VERTEX-a123e4.o

Overview

I’m trying to create a Directed Acylic Graph which would contain Edges and Vertices and would allow me perform some topological sort on it aswell as other functions. My Vertices would contain a vector of edges which represent the edges that led up to the vertices dependencies and My Edge class declaration also contains a Vertices destination, which represents the destination vertex for that edge. Each time I try to compile my program I get this error error message

I tried forward declaring the classes in both the Edge.h and Vertex.h file.
I decided to do that because if I just include the header in either of them(ie include Vector.h in Edge.h to be able to use it, I get the error enter image description hereand based off research I found forward declaring was a way to help resolve it).
Is there a way around this?

Edge.H header file for Edge

Edge.cpp CPP file foe Edge

Vertex.cpp enter image description here

Vertex.h enter image description here

New contributor

JustAGirl is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.

LEAVE A COMMENT