Suppose in C++ you're doing too many recursive calls on a recursive function and getting a stack overflow error.
How would you rewrite this in a continuation-passing style to avoid the stack overflow?
I'm having a slight difficulty picturing this in C++.