I have 2 files that are both including the other file and I am getting strange errors.
#ifndef NODE_H
#define NODE_H
#include "model.h"
etc....
#endif
#ifndef MODEL_H
#define MODEL_H
#include "Node.h"
etc....
#endif
Here is my example code of what I am doing. Can somebody explain to me why this is not possible or allowed? And what I should do to get passed this problem.
Best Answer
You have a circular dependency between
Node
andmodel
.To deal with this, instead of...
...in model.h , forward declare...
...and this will allow you to have
Node& node;
in yourModel
class
.Or vice-versa.
Better still... see if you can revisit your design and eliminate this circular dependency.