#include #include #include #include class TestC { public: TestC*child1; TestC*child2; TestC*child3; TestC(int depth) { if (depth>0) { depth-=1; child1=new TestC(depth); child2=new TestC(depth); child3=new TestC(depth); } else { child1=NULL; child2=NULL; child3=NULL; } } ~TestC() { if (child1!=NULL) delete child1; if (child2!=NULL) delete child2; if (child3!=NULL) delete child3; } int Count() { int count=1; if (child1!=NULL) count+=child1->Count(); if (child2!=NULL) count+=child2->Count(); if (child3!=NULL) count+=child3->Count(); return count; } }; int main(int argc, char*argv[]) { if (argc<3) { printf("TestC \n"); return 0; } int depth=atoi(argv[1]); int reps=atoi(argv[2]); printf("TestC started depth=%d reps=%d\n",depth,reps); int count = 0; for(int rep=0; repCount(); delete t; } printf("TestC count=%d\n", count); }