Question: I am having trouble with my code. This is what it has currently, but it need to be altered. To follow the listed parameters below
I am having trouble with my code. This is what it has currently, but it need to be altered. To follow the listed parameters below this is C++
The single quaternary operator # is a variation of the typical conditional expression operator. Like the ternary conditional expression operator, the remaining three operands are delimited only by whitespace. This expression is evaluated as follows. If the expression to the left of the operator # is less than 0, the value of the expression is the value of the first expression after the operator #. If it is equal to 0, the value of the expression is the value of the second expression after the operator #. If it is greater than 0, the value of the expression is the value of the third expression after the operator #.
class Ternary : public SubExpression { public: Ternary(Expression *left, Expression *right, Expression *condition) : SubExpression(left, right) { this->condition = condition; } int evaluate() { return condition->evaluate() ? left->evaluate() : right->evaluate(); } private: Expression *condition; };
This is where its called for in my subexpression.cpp
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
