#ifndef _STACKNODE_H_ #define _STACKNODE_H_ class StackNode { public: StackNode(void * const payload); /* This const annotation on the StackNode type for the argument 'next' promises that we will * not use this argument to modify the StackNode the argument points to. */ StackNode(void * const payload, const StackNode * const next); void *getPayload() const; const StackNode *getNext() const; private: void *payload_; /* Note that because our constructor takes a pointer to a const StackNode and we save it, * we must make next_ a const StackNode*, and consequently getNext(), which returns the * value of next_, must return a const StackNode*; any time you keep a reference to a const * T in a field, the const keyword tends to propagate far and wide through your code. * * This propagation isn't necessary if you don't hold onto a const T argument, because you * just read, return and forget.*/ const StackNode *next_; StackNode(const StackNode &n); StackNode &operator=(const StackNode &rhs); }; #endif // _STACKNODE_H_