Question: C++ answers only I need help converting this .h and .cpp file into templates. Node.h #ifndef NODE_H #define NODE_H #include #include using namespace std; class
C++ answers only
I need help converting this .h and .cpp file into templates.
Node.h
#ifndef NODE_H #define NODE_H #include
using namespace std;
class node { public: node(); node(int); node(int, node *); node(const node& orig); ~node();
void printAll(); node* GetNextNode() const { return nextNode; }
void SetNextNode(node* _nextNode) { nextNode = _nextNode; }
int GetValue() const { return value; }
void SetValue(int _value) { value = _value; } private: int value; node *nextNode;
};
#endif /* NODE_H */
Node.cpp
#include "node.h"
node::node() : value(0), nextNode(NULL){ }
node::node(int _value): value(_value), nextNode(NULL) { }
node::node(int _value, node *_nextNode) : value(_value), nextNode(_nextNode) { }
node::node(const node& orig) : value(orig.GetValue()), nextNode(orig.GetNextNode()) { }
node::~node() { }
void node::printAll(){ cout << "Node content:" << endl; cout << value << endl; cout << nextNode << endl; }
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
