An object-oriented example

4/7/98


Click here to start


Table of Contents

An object-oriented example

The problem

Example of an expression tree

Why are trees useful?

Properties of trees

Kinds of trees

The Expr hierarchy

How will we use Expr objects?

Memory management

Expression tree memory strategy

We can already declare class Expr

Representing integers

Declaration of IntExpr

Implementation

Implementation of IntExpr

Class OpExpr

Class OpExpr declaration

OpExpr implementation

Classes UnaryExpr and BinaryExpr

UnaryExpr declaration

UnaryExpr implementation

BinaryExpr declaration

BinaryExpr implementation

Abstract base classes

Properties of abstract base classes

Declaring a pure virtual

Rules for abstract base classes

Class Expr revisited

Class OpExpr revisited

Homework (due Monday)

C++ puzzle (extra credit)

C++ puzzle, continued

Author: Andrew Koenig

Email: ark@research.att.com

Home Page: http://www.research.att.com/info/ark