It's actually not a good idea for a C++ program to call its own main
function. In fact, this leads to undefined behavior, which means that you have no guarantees about the behavior of the program. It could crash, or proceed with corrupt data, or format your hard drive, etc. (that last one is unlikely, though).
I think that this reflects a more fundamental problem with how your program works. If you want data to persist across functions, you need to place that data somewhere where it won't get clobbered by other functions. For example, you could put the data in the heap, then pass pointers to the data around. Or, you could define it as a local variable in main
, then pass it down into functions and have those functions return when they're done. You could also consider making objects representing the data, then passing those objects across the different functions.
Without seeing your code, I doubt I can give a more specific answer than this. When designing programs, keep the data flow in mind. Think about what data needs to go where and how you're going to get it there.
Hope this helps!