Defining an array struct
Hey. I have a struct like this:
1 2 3 4 5
|
struct individual
{
int *x;
float profit;
};
|
And I want to do something like this:
struct individual Ant[MAX_ANT];
But the MAX_ANT variable should be changed by the user... How can I do that?
Normally it is like this:
#define MAX_ANT 50
But I dont want it as a constant... so please help... thanks in advance...
By using vectors:
1 2
|
vector<individual> ants;
for (int i=0;i<antCount;i++)ants.push_back(individual(...));
|
Topic archived. No new replies allowed.