I guess I've got a couple of days of reading and experimenting
jlb. I hadn't realized how comprehensive C++ generators are and I want to have a good understanding of the implications, not just adapt an example.
While I was posting the code
kbw, that was one of the first things I had contemplated using <array>.
As a rule, you should avoid using global variables.
|
From my limited knowledge, I would disagree with that as it's implications on the stack, but as I don't really know how arrays and vectors are constructed. Would I be correct in assuming, it's only the pointer to that container that's on the stack, 8 bytes in my case, rather than 36*8 (288) bytes, plus overhead for the container. When I get to that, I'll just trace into it with GDB and then I'll know, hopefully. Then I might be dealing with compiler options I'm not aware of.
Generally I like to keep main () as clean as possible or at least at a glance be able to recognize program flow. Functions like ShowStats () could just as well have been inserted at line 44, otherwise be it in functions/subroutine or main, I like to avoid nesting any deeper than 4 levels of braces.
Fundamentally, I consider functions that don't return a value a subroutine, but I do concur how ones that return values should be re-entrant. Not exactly sure how I would go about excluding local aka temporary variables from every situation, but first random numbers and then I can deal with that.