-1
I’m having trouble compiling this code, it returns me two errors while running it:
vector<bool> cp( size );
// determine crossover point (randomly)
for( int i = _numberOfCrossoverPoints; i > 0; i-- )
{
while( 1 )
{
int p = rand() % size;
if( !cp[ p ] )
{
cp[ p ] = true;
break;
}
}
}
the first error is related to the definition of p, it says that it occurs divided by zero.
the second error is related to trying to access cp with such p, it says iterator not dereferencable.
I wanted to understand why these errors are returned and how to fix them.