Question
/** @file Node.cpp Listing 4-2 */ #include Node.h #include #include template Node::Node() : next(nullptr) { } // end default constructor template Node::Node(const ItemType& anItem) :
/** @file Node.cpp
Listing 4-2 */
#include "Node.h"
#include
#include
template
Node::Node() : next(nullptr)
{
} // end default constructor
template
Node::Node(const ItemType& anItem) : item(anItem), next(nullptr)
{
} // end constructor
template
Node::Node(const ItemType& anItem, Node* nextNodePtr) :
item(anItem), next(nextNodePtr)
{
} // end constructor
template
void Node::setItem(const ItemType& anItem)
{
item = anItem;
} // end setItem
template
void Node::setNext(Node* nextNodePtr)
{
next = nextNodePtr;
} // end setNext
template
ItemType Node::getItem() const
{
return item;
} // end getItem
template
Node* Node::getNext() const
{
return next;
}
/** @file Node.h
Listing 4-1 */
#ifndef _NODE
#define _NODE
template
class Node
{
private:
ItemType item; // A data item
Node
public:
Node();
Node(const ItemType& anItem);
Node(const ItemType& anItem, Node
void setItem(const ItemType& anItem);
void setNext(Node
ItemType getItem() const ;
Node
};
The following will need to be modified:
- Node.cpp: all three constructors need to be modified to handle prev
- Node.cpp: add setPrev(), getPrev() implementations
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started