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

Popular posts from this blog

Android layout hidden on keyboard show -

google app engine - 403 Forbidden POST - Flask WTForms -

c - Why would PK11_GenerateRandom() return an error -8023? -