|
|
|
|
|
by npsimons
4898 days ago
|
|
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?
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...