I've been having a bit of trouble with a piece of code, where I'm trying to call a function on the object being pointed to.
I'm afraid I may be using these incorrectly (I've been programming in c# for the last year or so, and am pretty rusty with c++ pointers) and I would welcome any help or insight anyone may be able to provide.
I will post three snippits of code, first a function which is giving me an issue (it is either telling me the left hand operand must be a struct/class/union, or if i use the deference operator it tells me that I have a syntax error '.') the second will the be trinaryGraph specification file and the third will be my node specification file. The code is a bit sloppy, It is meant to be used with a few other data containers not yet finished.
~Problem Code
~TrinaryGraph SpecificationCode:template <class item> Node<item> TrinaryGraph<item>::getNodeByPos(int x,int y,int z)//will be cleaned up by a data container containing 3 float values { Node<item> *tempNode; tempNode=rootNode; if (x==0 && y==0 && z==0) return *rootNode; while(int iX=0 <= x) { if (tempNode.getLeftNode()==NULL) return NULL; tempNode=tempNode.getLeftNode(); iX++; } while(int iY=0 <= y) { if (tempNode.getDownNode()==NULL) return NULL; tempNode=tempNode.getDownNode(); iY++; } while(int iZ=0 <= z) { if (tempNode.getRightNode()==NULL) return NULL; tempNode=tempNode.getRightNode(); iZ++; } return tempNode; }
~Node specificationCode:template <class item> class TrinaryGraph { public: ///////CONSTRUCTORS/////// TrinaryGraph(int xDim,int yDim,int Zdim, float step=1); ~TrinaryGraph(); /////MODIFICATION MEMBER FUNCTIONS///////// Node<item> getNodeByPos(int x,int y,int z); void createGraph(Node<item> current,int x=0,int y=0,int z=0); //data to fill must be hardcoded at this time void fillGraphFaces(int x=0,int y=0,int z=0); void fillGraph(Node<item> currentNode); void fillNodeAtLocation(int x,int y,int z); void swap(Node<item> first,Node<item> second); void swap(int x1,int y1, int z1, int x2, int y2, int z2); ///TODO: faux random-access, matching(recursively) private: struct dims { int x,y,z; }; dims dimensions; Node<item>* rootNode; void fillGraphFaces(Node<item> currentNode, int x,int y,int z); };
I thank you for your time.Code:template <class item> class Node { public: /////CONSTRUCTORS////// Node(); Node(item idata); ~Node(); //MODIFICATION MEMBER FUNCTIONS/// void setData(item data); void setLeftNode(Node<item> newNode); void setDownNode(Node<item> newNode); void setRightNode(Node<item> newNode); void createLeftNode(item idata); void createDownNode(item idata); void createRightNode(item idata); void createLeftNode( ); void createDownNode( ); void createRightNode( ); void operator = (Node<item> source); void Node<item>::operator == (Node<item> source); //CONSTANT MEMBER FUNCTIONS// item getData() const; Node<item> getLeftNode() const; Node<item> getDownNode() const; Node<item> getRightNode() const; private: item data; Node<item>* leftNode; Node<item>*downNode; Node<item>* rightNode; };




Reply With Quote