Hey everyone,
I'm relatively new to C++, cant seem to find a solution to my problem.
I'm trying to randomly generate an array of class objects. I'm using rand() to generate a number 1-3, for the number of objects to generate.
For some reason when I use:
int c_gen = rand()%3+1;
ob ob1[c_gen];
I get a compile error:
error C2057: expected constant expression
error C2466: cannot allocate an array of constant size 0
error C2133: 'ob1' : unknown size
But, if I use any given number such as 3:
ob ob1[3];
The program compiles fine.
I'm not sure what the problem, I even output c_gen just to see if it was generating a number, and it is.