Question
#ifndef NODES_H #define NODES_H #include #include using namespace std; // Abstract class. Base class for StringNode, IntegerNode, and FloatNode // // Do NOT change this
#ifndef NODES_H #define NODES_H
#include
using namespace std;
// Abstract class. Base class for StringNode, IntegerNode, and FloatNode // // Do NOT change this class class DataNode { public: virtual void printTo(ostream &os) = 0; // pure virtual method, makes the class Abstract virtual ~DataNode(); // labeling the destructor as virtual allows // the subclass destructors to be called };
// Uses double dispatch to call the overloaded method printTo in the // DataNodes: StringNode, IntegerNode, and FloatNode // // Do NOT change this method ostream& operator
// Do NOT change this method DataNode::~DataNode() {}
class StringNode : public DataNode { public: string* mystring = nullptr;
// Add constructor, destructor, and printTo methods };
class IntegerNode : public DataNode { public: int myinteger = 0;
// Add constructor, destructor, and printTo methods };
class FloatNode : public DataNode { public: float myfloat = 0.0;
// Add constructor, destructor, and printTo methods };
#endif /* NODES_H */
Complete the StringNode, IntegerNode, and FloatNode classes. Each class requires constructor, destructor, and printTo methods. Each constructor should accept an argument and save that value within the node. The printTo method is an example of "double dispatch. https://en.wikipedia.org/wiki/Double_dispatch Once the data node classes are complete, use the comments within driver.cpp as instructions on what functionality should be added to the main method. Complete the StringNode, IntegerNode, and FloatNode classes. Each class requires constructor, destructor, and printTo methods. Each constructor should accept an argument and save that value within the node. The printTo method is an example of "double dispatch. https://en.wikipedia.org/wiki/Double_dispatch Once the data node classes are complete, use the comments within driver.cpp as instructions on what functionality should be added to the main methodStep 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