/****************************************************** Name: Filename: RecurFunc.cpp ******************************************************/ //Member Function Definitions For RecurFuncDrv.cpp #include "RecurFunc.h" using namespace std; RecurFunc::RecurFunc() //Constructor { numberOfLevels = 0; } RecurFunc::~RecurFunc() //Destructor { } void RecurFunc::recursiveFunc(int numberOfLevels) { // Variables Are Given Static Property To Retain Their Values Between Calls static int spaces = 0,currentLevel = 0; // Increment The Level Number By One currentLevel++; // Spaces Variable Is Used To Indent Messages spaces++; // Display The Message With The Appropriate Indentation cout << setw(spaces) << " "; cout << "This was written by call number " << currentLevel << ".\n"; // Call Recursively Till We Reach 1 if (numberOfLevels > 1) recursiveFunc(numberOfLevels - 1); // Again Display The Message With The Proper Indentation cout << setw(spaces) << " "; cout << "This ALSO written by call number " << currentLevel << ".\n"; // Decrement The Offset And currentLevel By 1 Since We Are About To Return // To The Parent Function spaces--; currentLevel--; }