Hello Someone yesterday tried helping me and this is actually his code, which I'm using to demonstrate the problem im encountering. Below is the header.h file and main file respectively. He claimed that this code would work but I cannot get a successfull result. I think the reason why is cause edge is reliant on vertex and vertex is reliant on edge which isnt allowed. Any way around this?
#pragma once
#include <vector>
class Edge {
public:
Vertex* vertex1;
Vertex* vertex2;
Edge(Vertex* v1, Vertex* v2) : vertex1{ v1 }, vertex2(v2) {}
};
class Vertex {
public:
std::vector<Edge*> incidentEdges;
void addEdge(Edge* edge) {
incidentEdges.push_back(edge);
}
};
class Graph {
public:
std::vector<Vertex*> vertices;
std::vector<Edge*> edges;
};
#include <iostream>
#include "Header.h"
int main()
{
std::cout << "Hello World!\n";
}