Greetings everyone. Having an issue compiling my script containing the following function. Three errors occur, all on the same line where I set distance += to distances [][]:
error C2108: subscript is not of integral type error C2108: subscript is not of integral type error C2297: ‘+=’ : illegal, right operand has type ‘double (*)[15]’
Assistance would be much appriciated.
double S_initial; double distances [15][15]; double order [15]; void Initialize() { double x, y ,z; double distance = 0; for (int i = 0; i <= 14; i++) { x = order [i]; y = order [i + 1]; distance += distances [x][y]; } S_initial = distance; }
Well, the array subscripts
xandyare not of an integral type likeint, but of typedouble:And something like the 1.46534th element of an array doesn’t make sense, so the compiler complains.