#ifndef Nodes_H #define Nodes_H /////////////////////////////////////////////////////////////////////////// // Nodes.h - demonstrate how to define a template node class // // ver 1.1 // // Language: Visual C++, 2008 // // Platform: Dell Precision T7400, Vista Ultimate, SP1 // // Application: CSE382 - Algorithms and Data Structures Demo, Fall 2008 // // Author: Jim Fawcett, Syracuse University, CST 4-187, // // (315) 443-3948, jfawcett@twcny.rr.com // /////////////////////////////////////////////////////////////////////////// /* * Module Operations: * ================== * Provides a template Node class that has successor pointer and value * members, and value() and next() member functions. * * Build Process: * ============== * cl /D:TEST_NODES Nodes.cPP * * Maintenance History: * ==================== * ver 1.1 : 02 Sep 08 * - cosmetic changes to prologue * ver 1.0 : 28 Aug 08 * - first release */ #include namespace CppNodes { template class Node { public: Node(Node* pNode, const T& t=0) : next_(pNode), t_(t) {}; T& value() { return t_; } Node*& next() { return next_; } // Compiler generated copy and assignment are shallow. // That makes sense for a Node class. private: Node* next_; T t_; }; } #endif