   Creating a launcher in C++ (problems)
  Hi.I''ve created a termite simulation in C++ which loads in a window (it features a grid where termites use emergent behaviour to create mounds of woodchips).Now that part is finished, and my supervisor (I''m writing this program so he can demo it in a lab to his AI students) has asked me to add some buttons/sliders so that the number of termites/woodchips or the speed of the sim can be changed without having to compile.Now at the moment my program simply starts by opening up a window and starting the simulation inside it. What I want to do is have a launcher that appears first so you can change the settings and then click SIMULATE! or RUN! or something. The main problem I have is that the only way I could have an array of objects initialize with a (variable) number of items is to specify a DEFINE in the header file, for example :Header File contains :#define MAP_WIDTH 50#define MAP_HEIGHT 50#define WOODCHIPS 1000#define TERMITES 100CPP file contains :int MAP[MAP_WIDTH * MAP_HEIGHT];int WOOD[WOODCHIPS * 2];Termite Them[TERMITES];All those arrays are global - so that they can be used both by the main code and the code within the Termite objects.Using DEFINE was the only way I could get those arrays to initialise, because otherwise I get an error message like :-----CODE------int Termite_array_size = 100;Termite Them[Termite_array_size];------------------error C2057: expected constant expressionerror C2466: cannot allocate an array of constant size 0So, how would I write this launcher so that these variables (currently DEFINEd in the header file) to be changable? Can you actually specify DEFINITIONS like this like you can do with normal variables?Any help would be great!Cheers,SFA. 
  Search for 'dynamic arrays' on this forum. Basically, dynamically allocating an array involves holding a pointer to it, allocate memory using new and free using delete, like thisTermite* termites;termites=new Termite[100];//later ondelete[] termites   Note that new throws std::bad_alloc if the computer is out of memory.A forum search will give you more information about dynamic allocation that you'd ever need to know [edit]Or a std::vector [/edit]   [edited by - CloudNine on February 20, 2004 7:21:40 AM];  that doesn''t look like c++ use a std::vector which you can resize. 