The maximum recursion depth depends on the amount of memory used by the function(s), the amount of memory on your platform and the limits (if any) by the OS or the compiler.
In a recursive call, memory is occupied by:
- The overhead of a function call
- The memory occupied by the parameters passed.
- The memory occupied by local variables
A recursive function with no parameters and no local variables will have a higher possible depth (number of recursive calls) than a function that passes a lot of large objects and occupies a lot of local variables.
So, the answer to your question is: the maximum number of recursive calls depends on the amount of memory occupied by a recursive call, the amount of memory on the system and any limits imposed by the compiler or operating system. Different recursive functions occupy different amounts of memory.
If you know all these items, then you can calculate the maximum number of possible recursions.
C++that defines the maximum depth. The maximum depth is dependent on CPU architecture, compiler-specific implementation details, and the actual function being recursed (along with child functions it calls). Like any other problem, sure, if you know all the parameters you can determine a solution.... but in this case it's probably much easier to just do the explicit call and see what you get. - mah[temp.inst]that says there is an implementation defined quantity. - NathanOliver