All pastes #105880 Raw Edit

Anonymous

public text v1 · immutable
#105880 ·published 2006-07-29 23:33 UTC
rendered paste body
typedef boost::shared_ptr<Base> Expression;

class BinaryOperator {
    Expression left;
    Expression right;
public:
    BinaryOperator(Expression lval, Expression rval);
    template<typename T> virtual T GetValue(T (Base::*fun)(void) const) const = 0;
};
class Add : public BinaryOperator {};
class Subtract : public BinaryOperator {};

Creation:
	| expr '+' expr
	  {
		$$ = e(new tValue::Add(*$1, *$3));
		delete $1, $3;
	  }

Use:
    int currentSize = currentSizeValue.getValue();