I've written code like this in C to create library functions that will be linked in to other projects, but where there is no 'main' function in the C file. Do people use C++ the same way, or is it best practice to include 'main?'
It's the same as in C. The observation here is that variables with static storage duration can be initialized by running user code before main() begins.
[1] : https://progforperf.github.io/Expert_C_Programming.pdf