www.pudn.com > container.rar > element.h
// Fig. 15.3: listnd.h // ListNode template definition #ifndef ELEMENT_H #define ELEMENT_H template< class TYPE > class Container; // forward declaration templateclass Element { friend class Container< TYPE >; // make List a friend public: Element( const TYPE & ); // constructor TYPE getData() const; // return data in the node private: TYPE data; // data int index; Element< TYPE > *nextPtr; // next node in the list }; // Constructor template Element< TYPE >::Element( const TYPE &value ) { data = value; nextPtr = NULL; } // Return a copy of the data in the node template< class TYPE > TYPE Element< TYPE >::getData() const { return data; } #endif