I have a global array of size DIMENSIONS
: DIMENSIONS
is a static global variable. I can change the hardcoded DIMENSIONS
variable without issues in compilation or execution, but is there a way to determine this value at compile time versus run time?
const static unsigned int DIMENSIONS = 2;
std::array<double, DIMENSIONS> arr;
// ...
// ...
// ...
int main (int argc, char* argv[]) {
// argv[0] contains value '4'
}
If I made DIMENSIONS
non-constant non-static, is there a way to reinitialize it as argv[0]
in main()
and have arr
still instantiate properly?
I'd like to control the dimensionality of my program (it's meant for hill climbing optimization) through the command line. I understand arrays cannot have dynamic sizing and besides VLAs, must have their size declared at compile time, not run time. I specifically need a global non-VLA, though.
Aucun commentaire:
Enregistrer un commentaire