]> git.donarmstrong.com Git - mothur.git/commitdiff
re-enabling the destructor to enable deletion of dynamically allocated memory.
authorAbu Zaher Md. Faridee <zaher14@gmail.com>
Thu, 23 May 2013 21:50:24 +0000 (03:50 +0600)
committerAbu Zaher Md. Faridee <zaher14@gmail.com>
Thu, 23 May 2013 21:50:24 +0000 (03:50 +0600)
randomforest.hpp

index 5dd1876fcb4a796839173c16df01177235b74078..d0ac1ec063d46d4ff1367e87cf322870f7e49a9c 100644 (file)
@@ -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.
     
     //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<AbstractDecisionTree*>::iterator it = decisionTrees.begin(); it != decisionTrees.end(); it++) {
-//            // we know that this is decision tree, so we can do a dynamic_case<DecisionTree*> here
-//            DecisionTree* decisionTree = dynamic_cast<DecisionTree*>(*it);
-//            // calling the destructor by deleting
-//            delete decisionTree;
-//        }
-//    }
+    virtual ~RandomForest() {
+        for (vector<AbstractDecisionTree*>::iterator it = decisionTrees.begin(); it != decisionTrees.end(); it++) {
+            // we know that this is decision tree, so we can do a dynamic_case<DecisionTree*> here
+            DecisionTree* decisionTree = dynamic_cast<DecisionTree*>(*it);
+            // calling the destructor by deleting
+            delete decisionTree;
+        }
+    }
     
     int calcForrestErrorRate();
     int calcForrestVariableImportance(string);
     
     int calcForrestErrorRate();
     int calcForrestVariableImportance(string);