From 5d618cc8affb959ac64f9cf502dbddf53fb5e7c5 Mon Sep 17 00:00:00 2001 From: Adrian Kummerländer Date: Sat, 10 Mar 2012 19:14:27 +0100 Subject: Moved static_cast needed for accessing the specific solve methods of the two derivatives of Node into a template function --- tree.cpp | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'tree.cpp') diff --git a/tree.cpp b/tree.cpp index ee45e57..340685f 100644 --- a/tree.cpp +++ b/tree.cpp @@ -1,21 +1,24 @@ #include "tree.h" -#include Node::Node() { } +template +double Node::castSolve (Node *node) { + T *tmp = static_cast( node ); + return tmp->solve(); +} + double Node::solve() { switch (this->type) { case OPERAND_NODE: { - OperandNode *tmp = static_cast( this ); - return tmp->solve(); + return this->castSolve( this ); } case OPERATOR_NODE: { - OperatorNode *tmp = static_cast( this ); - return tmp->solve(); + return this->castSolve( this ); } } } -- cgit v1.2.3