c++ - Circular dependency -
i have class called point , other namespace containing tree class. tree balanced binary search tree, , uses function compare compare keys , puts them in right place. tree contains points, , each point have know tree belongs to, tried add pointer tree in point class this:
class point{ public: double x, y; std::set<std::multiset<point,tree::compare()>*>s; //tree name of namespace // other data } my problem since tree uses point.h(because stores points) cant add layerthree.h cant use tree::compare() in point.h. tried add new file cmp.h , put compare function in it, did not help. should do?
edit: can not put both tree , point class in same file because there other files needs include point.h
as jepessen mentioned need forward declaration. here example:
class depends on class b , class b depends on class a, use forward declaration this:
in class "b.h":
#include "a.h" class b { //do stuff }; and in class "a.h":
// forward declaration of class b, tells compiler not worry // class b somewhere later in compilation class b declared class b; class { //do stuff };
Comments
Post a Comment