Earlier quoted context omitted.
It strikes me that your argument taken to the extreme is that everybody should program in assembly language because you can do anything, anytime, anywhere. Well, at least as far as control flow structures are concerned. Certainly C is preferable to C++ if you want simple and malleable code. Do you also prefer if-else to switch statements? (I'm not sure.) Do you like to use goto? (I doubt it.) Do you eschew the use of…
Not to mention that it's essential for initializing some constant variables; I have yet to find a better way to do: const int count = argc > 1 ? atoi(argv[1]) : 1000000; For quick test programs where I might want to change some number of iterations without having to recompile, but I also don't want to have to provide an argument every time I run it.
Is there anything wrong with keeping the default value as a separate constant?
const int kDefaultValue = 1000000;
int value = kDefaultValue;
if (argc > 1) {
value = std::atoi(argv[1]);
}
const int count = value;
Personally I much prefer using [program options][1] from the boost project (since we are talking about C++ here). Most projects already have this as a dependency, and its quite easy to setup. It also properly handles your types.[1]: http://www.boost.org/doc/libs/1_52_0/doc/html/program_option...