#include #include using namespace std ; #include #include "IntFamily.h" void printFamily(char *famName, IntFamily *famObj) { int famSize = famObj->getSize() ; cout << endl << "The family that is " << famName << endl ; cout << " " << famObj->getParent() << "-> " ; for (int i=0; igetChild(i) << ", " ; if (famSize>0) cout << famObj->getChild(famSize-1) ; cout << endl ; } void testDestruction(int N) { int Ntenth = N/10 ; cout << endl << "Testing " << N << " create/destroy cycles" << endl ; for (int i=0; iaddChild(i+j) ; delete ignoreMe ; } cout << endl << "Destruction successful for " << N << endl ; } main(int argc, char *argv[]) { int i ; IntFamily *odd = new IntFamily(1) ; for (i=11; i<=20; i += 2) odd->addChild(i) ; IntFamily *even = new IntFamily(2) ; for (i=12; i<=20; i += 2) even->addChild(i) ; IntFamily *only = new IntFamily(333) ; printFamily("odd", odd) ; printFamily("even", even) ; printFamily("only", only) ; int cycles ; if (argc>1) cycles = atoi(argv[1]) ; else cycles = 1000000 ; testDestruction(cycles) ; }