I have this section of code that keeps giving a vector subscript out of range error, but I cant figure out why.
the vector is defined as
vector< vector<double> > distance;
for the test I am doing, point->size() = 3, and through the debugger I have verified that the matrix does get resized to 3 by 3, however when it gets to [2][2] it throws the vector subscript out of range error. How do I fix this?
//resize matrix
distance.resize(point->size());
for (int i = 0; i < point->size(); i++)
distance[i].resize(point->size());
for (int i = 0; i < point->size(); i++)
{
for (int j = 0; j < point->size(); j++)
{
cout << i << ", " << j << endl;
distance[i][j] = *removed*;
}
}