I have two classes, Graph and Frame, that cross reference each other.
This is due to need of information on what graphs does one frame own and get the owning frame from graph.
So when frame are updated with a new graph, the added graph has to call its old owner frame to release it before being added by the new.
I have declared the class Frame before the graph but it won't work.
class Frame;
class Graph;
// definition of Graph
class Graph
{
private:
Frame* Owner;
public:
Graph(const Graph& copy): Owner(copy.GetOwner()) {}
bool UpdateOwner(Frame& owner)
{
// release it from previous owner
if (Owner.IsValid())
Owner.release_graph(this);
// insert it into new owner
owner.add_graph(this);
Owner = owner;
return;
}
BluePrint_Frame* GetOwner() const
{
return Owner;
}
};
// and the definition of Frame
class Frame
{
vector<Graph> graphs;
void release_graph(Graph& graph)
{
// find graph and erase it from list
...
return ERROR;
}
void add_graph(Graph& graph)
{
graphs.push_back(graph);
return ERROR;
}
}
When compiling the code gives the error that Frame is undefined, due to class function of Frame IsValid(), release_graph, and add_graph.