#include "common.h" int depth = 8; class Local { private: const static int DEFAULT_DEPTH = 5; int depth; void recurse(int depth); void init(int depth); public: Local(); Local(int depth); ~Local(); void recurse(); }; Local::Local(){ init(DEFAULT_DEPTH); } Local::Local(int depth){ init(depth); } void Local::init(int depth){ this->depth = depth; } Local::~Local(){ depth = 0; } void Local::recurse(){ recurse(depth); } void Local::recurse(int depth){ cout << "Recursing to depth " << depth << ".\n"; if(depth > 0) { recurse(depth-1); } cout << "Returning from depth " << depth << ".\n"; } int main(int argc, char* argv[]) { cout << "*** Recursion to depth " << depth << "\n"; Local l1(depth); l1.recurse(); cout << "*** Recursion to default depth\n"; Local l2; l2.recurse(); { int depth = 3; cout << "*** Recursion to depth " << depth << "\n"; Local l1(depth); l1.recurse(); } }