c++ defining a Node class, which has a private variable of Node (a Node for use in a*) -
i new c++ , trying define node class holds information node, in case node parent node can trace optimal route using a* search.
so far have tried (node.h file):
class node{ private: int xcoord; int ycoord; int value; int hueristiccost; int pathcost; class node parent; public: node(int xc, int yc, int value); int getxpos(); int getypos(); int getvalue(); };
but throws compilation error:
node.h:10:13: error: field ‘parent’ has incomplete type
i missing stupidly obvious, how go completing this?
a member must complete type (as error message oblivious tells you). means can´t have forward declared member.
notice, can use node
(as complete type) inside node class.
however, defining member of type node
still not possible, because lead infinit recursion. want node*
if have tree-like model. notice class foo* member;
indeed possible. usual solution if cant avoid forward declaration.
Comments
Post a Comment