From: Abu Zaher Md. Faridee Date: Thu, 23 May 2013 21:50:24 +0000 (+0600) Subject: re-enabling the destructor to enable deletion of dynamically allocated memory. X-Git-Url: https://git.donarmstrong.com/?p=mothur.git;a=commitdiff_plain;h=f67ee238c956bb84cfc743b86c41a7e23f1980ba re-enabling the destructor to enable deletion of dynamically allocated memory. --- diff --git a/randomforest.hpp b/randomforest.hpp index 5dd1876..d0ac1ec 100644 --- a/randomforest.hpp +++ b/randomforest.hpp @@ -30,14 +30,14 @@ public: //NOTE:: if you are going to dynamically cast, aren't you undoing the advantage of abstraction. Why abstract at all? //could cause maintenance issues later if other types of Abstract decison trees are created that cannot be cast as a decision tree. -// virtual ~RandomForest() { -// for (vector::iterator it = decisionTrees.begin(); it != decisionTrees.end(); it++) { -// // we know that this is decision tree, so we can do a dynamic_case here -// DecisionTree* decisionTree = dynamic_cast(*it); -// // calling the destructor by deleting -// delete decisionTree; -// } -// } + virtual ~RandomForest() { + for (vector::iterator it = decisionTrees.begin(); it != decisionTrees.end(); it++) { + // we know that this is decision tree, so we can do a dynamic_case here + DecisionTree* decisionTree = dynamic_cast(*it); + // calling the destructor by deleting + delete decisionTree; + } + } int calcForrestErrorRate(); int calcForrestVariableImportance(string);