I am getting a warning when writing to a dynamically allocated array that I can't seem to figure out. Visual Studio says that there is a "buffer overrun." However, I don't see what would cause that error. For reference, here is my code:
//Initialize the cost matrix
int numMembers = 10;
int** costMatrix = new int* [numMembers];
for (int i = 0; i < numMembers; i++)
{
costMatrix[i] = new int[5];
}
for (int i = 0; i < numMembers; i++)
{
for (int j = 1; j < 3+1; j++)
{
int index = 3;
costMatrix[i][index] = j; //Set cost matrix
}
}
Any help would be greatly appreciated. Thanks!