Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

#ifndef NODES_H #define NODES_H #include #include using namespace std; // Abstract class. Base class for StringNode, IntegerNode, and FloatNode // // Do NOT change this

image text in transcribed

#ifndef NODES_H #define NODES_H

#include #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 method

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

Building Database Driven Catalogs

Authors: Sherif Danish

1st Edition

0070153078, 978-0070153073

More Books

Students also viewed these Databases questions

Question

=+1 What would you do if you were the IHR manager?

Answered: 1 week ago