Question: (C++) //Node.cpp #include #include #include #include #include #include #include Node.h using namespace std; // constructors Node::Node() { dataField = valueType(); linkField = NULL; } Node::Node(Node
(C++)

//Node.cpp
#include
using namespace std;
// constructors
Node::Node() { dataField = valueType(); linkField = NULL; }
Node::Node(Node *initLink) { dataField = valueType(); linkField = initLink; }
Node::Node(const valueType& initData) { dataField = initData; linkField = NULL; }
Node::Node(const valueType& initData, Node *initLink) { dataField = initData; linkField = initLink; } // getters - methods to GRAB data fields
valueType Node::getData() const { return dataField; }
Node* Node::getLink() const { return linkField; }
Node* Node::getLink() { return linkField; }
// setters - methods to SET data fields
void Node::setData(const valueType& newData) { dataField = newData; }
void Node::setLink(Node *newLink) { linkField = newLink; }
//Node.h
#ifndef NODE_H #define NODE_H
typedef double valueType;
class Node { public:
// constructors
Node(); Node(Node *initLink); Node(const valueType& initData); Node(const valueType& initData, Node *initLink); // getters - methods to GRAB data fields
valueType getData() const; Node* getLink() const; Node* getLink();
// setters - methods to SET data fields
void setData(const valueType& newData); void setLink(Node* newLink);
private: valueType dataField; Node *linkField; };
#endif /* NODE_H */
Now, using Node.h and Node.cpp, create a new main() function in a file named listPlay.cpp that lightly "plays with" a linked list made up of Node instances, meeting the following requirements: It should ask the user to enter as many numeric values as they would like, asking them to enter a value of -1 to indicate that they are finished (the - 1 is intended to be a sentinel, not actual data). Each (non-sentinel) value entered should be added as a Node to a linked list made up of dynamically- allocated Node instances then note that you can make nodePtr point to a newly-allocated Node instance using: nodePtr = new Node; // or call whichever constructor you wish
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
