I'm a newcomer to C++, from C#. I wrote a program that prints an ASCII checkerboard with a side length of the number passed to it (link to original Code Golf). Here is its code (VC++):
stdafx.h
Checkers.cpp
I intentionally had a little fun optimizing prematurely here, i.e. generating the header ("+--+"
) and body ("|##| |"
) strings only once instead of every loop. What could I do to increase readability without getting rid of each-loop optimizations like this?
When is it okay to use non-type template parameters, like I did in body
? This means that you always have to rewrite your code when you want to offer a non-template alternative, correct?
Any other comments / suggestions?
Thanks!
(This is not an entry for the Code Golf contest, it is way too long for that.)