This preview shows page 1. Sign up to view the full content.
Unformatted text preview: CSE 335 Homework 3 Objectives: Implement class hierarchies using abstract classes and pure virtual functions. Description: In class, we discussed how to design a class hierarchy to implement arithmetic expres- sion trees. For this exercise, you are to implement these classes and add an operation to compute the value of an expression tree. For the first part, you will need to implement the concrete classes: Literal represents an integer literal in an expression (e.g., the 23 and the 3 in the expression 23- 3 ). Negate is a unary operator that changes the sign of another expression (e.g., in the expression- (23 + 4) the primary operator is negation). Add, Subtract, Multiply, and Divide are binary operators whose names should be self explana- tory. Initially, class Literal should merely provide an operation for returning its value, and the operator classes should provide operations for retrieving the expression or expressions upon which they operate. The second part of the assignment is concerned with actually computing the value ofoperate....
View Full Document
This note was uploaded on 12/14/2009 for the course CSE 335 taught by Professor Kraemer during the Fall '08 term at Michigan State University.
- Fall '08