Say I have a wrapper function that goes around some smaller recursive function. However, the wrapper, before calling the recursive function creates an object which the recursive function uses. How can I do this in c++? Do I just need to make it its own class? EDIT - I know if I can make it into a class and how to take it from there - but my question is do I need a class or can I somehow getaway without making one?
I made a generic example to clarify my question:
void wrapper()
{
Object myObject;
bool recurFun(int x)
{
// do some stuff with myObject
if (some condition){return recurFun(x-1)}
else {return true}
}
}
Please ignore any basic syntax type errors, it is not a working example simply one to help get my question across to you guys. Thanks!