Hi Im having a few problems with pointers and was wondering whether anyone can point me in the right direction.
I have the following code:
This forms part of a larger class which forms a simple linked list:Code:class LatticeNode { public: int num; Cell c; LatticeNode *next; LatticeNode *prev; Cell* getCell() { return c; } LatticeNode(Cell *c); };
Now im trying to use the getCell method from LatticeNode to return the object Cell c from the LatticeNode object, like so:Code:template< class T, int size> class Lattice { public: Lattice(); ~Lattice(); LatticeNode *getCurrent() { return current; } void polarise(); private: LatticeNode* current; };
Where signal(dt) is a function in the object Cell. If i call it like this then it crashes, and i dont understand why its causing this..Code:current->getCell()->signal(dt);
Im not sure on the return type for the getCell function .. do i return just c or a reference to &c?
I believe the Cell object is being created when i call the LatticeNode constructor, although am i pointing to something which doesnt exist??
Any help, suggestions welcomed!



LinkBack URL
About LinkBacks


