Understanding C++ Expression Templates - Angelika Langer
Understanding C++ Expression Templates - Angelika Langer
Understanding C++ Expression Templates - Angelika Langer
- No tags were found...
You also want an ePaper? Increase the reach of your titles
YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.
22OO Implementation à la GOFAbstractExprinterpret()TerminalExprinterpret()NonTerminalExprinterpret()Literalconst double vVariabledouble& vBinaryExprAbstractExpr* e1UnaryExprAbstractExpr* einterpret()interpret()AbstractExpr* e2interpret()v...vinterpret()SUMProductinterpret() interpret()... ...e1->interpret() + e2->interpret()e1->interpret() * e2->interpret()© Copyright 1995-2000 by <strong>Angelika</strong> <strong>Langer</strong>. All Rights Reserved.http://www.<strong>Angelika</strong><strong>Langer</strong>.com(43)last update: 11/7/2005 ,21:37The Abstract <strong>Expression</strong>sThe base classes that define the interface common to terminaland nonterminal expressions:class AbstractExpr {public:virtual double eval() const = 0;};class TerminalExpr : public AbstractExpr {};class NonTerminalExpr : public AbstractExpr {};© Copyright 1995-2000 by <strong>Angelika</strong> <strong>Langer</strong>. All Rights Reserved.http://www.<strong>Angelika</strong><strong>Langer</strong>.com(44)last update: 11/7/2005 ,21:37