struct ActivePoint {
int totq;
int valc[20];
int level;
double objval;
bool integer;
float allocate;
};
with an array: valc. This array has dimension 20, however it should have a dimension that is set at the time of construction (so the dimension should not be 20, but should be "d".
I tried to do so by using a class:
class ActivePoint {
public:
ActivePoint(int ic);
int totq;
int* valc;
int level;
double objval;
bool integer;
float allocate;
};
In both cases valc is the address of element 0, which is an int making valc an int*.
The correct approach is to allocate the array in the constructor using the new operator.
If you do this, then ic is your array dimension and this can be different for every ActivePoints object. Now if you have some hard-coded 20's floating around, then you will have problems.
You should be able to change the size of the array bu writing a method that allocates a new array of the new length, copies the current valc array into the new array, deletes valc, and then assigns the address of the new array to valc.
In short, any problems you are having are not in the code sample you posted.
However, all of your class data members are public. They need to be private.
You see, that valc member needs to be managed by ActivePoints member functions only. If it's not then anywhere in the program someone could alter valc incorrectly and crash the program.
Next, your activepoint::setdim needs to delete the current valc before placing a new address inside it. Otherwise, you can't delete the previous allocation. This is a memory leak.
Next, your ActivePoints constructor need to validate that the ic used as an argument is not zero or some negative number. I wouild llet this go until later and just be sure to use valid ic arguments.