Question: The interface describes an arithmetic expression that contains three virtual functions - The eval function calculates the value of the expression and returns that value.

 The interface describes an arithmetic expression that contains three virtual functions

The interface describes an arithmetic expression that contains three virtual functions - The eval function calculates the value of the expression and returns that value. The equals function will get an arithmetic expression as a parameter and return true with the expression value represented by this equal to the value of the expression represented by the parameter. The format function will return a string that represents the expression. Write the following classes that inherit from Expression: The Value class will represent a numeric value. It will contain one private double attribute that will represent the numeric value. Its eval function will return this value. The format function will return a string that contains only the numeric value. The Compund class will represent a complex arithmetic expression. The class will contain as attributes two Expression objects Write the following classes that inherit from the compound Compund - The Addition class that will represent an essay expression. The eval function returns the result of the connection between the two expression objects that are present as properties. The format function returns the string representation of the operands and the "+" sign in them. The Subtract class that will represent subtraction. The eval function will return the result of the subtraction between the two expression objects that are present as properties. The format function will return the string representation of the operands and the "" sign in them. You can run the main attached on the course website to check your answers. Remarks - Define the header files other than the Expression.h file in a file named Arithmetic.h. Configure all cpp files within a file named Arithmetic.cpp.

#ifndef EXPRESSION H #define EXPRESSION_H Expression Interface * class Expression public: virtual double eval(-0; virtual bool equals(const Expression&) - 0; virtual string format() - 0; #endif #ifndef EXPRESSION H #define EXPRESSION_H Expression Interface * class Expression public: virtual double eval(-0; virtual bool equals(const Expression&) - 0; virtual string format() - 0; #endif

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!