Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Node.h /** @file Node.h Listing 4-1 */ #ifndef _NODE #define _NODE template class Node { private: ItemType item; // A data item Node * next;

image text in transcribed

Node.h

/** @file Node.h Listing 4-1 */ #ifndef _NODE #define _NODE

template class Node { private: ItemType item; // A data item Node* next; // Pointer to next node

public: Node(); Node(const ItemType& anItem); Node(const ItemType& anItem, Node* nextNodePtr); void setItem(const ItemType& anItem); void setNext(Node* nextNodePtr); ItemType getItem() const; Node* getNext() const; }; // end Node

//#include "Node.cpp" #include "Node.h" #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; } // end getNext

#endif

Node.cpp

#include "Node.h" #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; } // end getNext

A Linked List with Node Class A Linked List with Node Class Write a main program (client program) that creates a linked list as in the following figure. nullptr "ef""gh item next tem next tem next Node.h and Node.cpp must be used to create the list

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Oracle9i Database Administrator Implementation And Administration

Authors: Carol McCullough-Dieter

1st Edition

0619159006, 978-0619159009

More Books

Students also viewed these Databases questions

Question

What is the difference between test data and live data?

Answered: 1 week ago