1: // Created by Frank M. Carrano and Tim Henry.
2: // Copyright (c) 2013 __Pearson Education__. All rights reserved.
4: /** @file Node.cpp
5: Listing 4-2 */
6: #include "Node.h"
7: #include <cstddef>
9: template<class ItemType>
10: Node<ItemType>::Node() : next(nullptr)
11: {
12: } // end default constructor
14: template<class ItemType>
15: Node<ItemType>::Node(const ItemType& anItem) : item(anItem), next(nullptr)
16: {
17: } // end constructor
19: template<class ItemType>
20: Node<ItemType>::Node(const ItemType& anItem, Node<ItemType>* nextNodePtr) :
21: item(anItem), next(nextNodePtr)
22: {
23: } // end constructor
25: template<class ItemType>
26: void Node<ItemType>::setItem(const ItemType& anItem)
27: {
28: item = anItem;
29: } // end setItem
31: template<class ItemType>
32: void Node<ItemType>::setNext(Node<ItemType>* nextNodePtr)
33: {
34: next = nextNodePtr;
35: } // end setNext
37: template<class ItemType>
38: ItemType Node<ItemType>::getItem() const
39: {
40: return item;
41: } // end getItem
43: template<class ItemType>
44: Node<ItemType>* Node<ItemType>::getNext() const
45: {
46: return next;
47: } // end getNext