I am creating a matrix, then I want to fill its values with 0.
I am getting an access violation error in this line:
mat1[x][y]=0;
But I don't see why.
This is my code:
vector<float>getJenksBreaks(vector<float>uFloats,const unsigned int uNumClass)
{
float* first(&uFloats[0]);
float* last(first + uFloats.size());
std::sort(first, last);
float **mat1 = new float*[uFloats.size()];
for (int i = 0; i < uFloats.size(); ++i)
{
mat1[i] = new float[uNumClass+1];
}
for (unsigned long x=0;x<uNumClass+1;x++)
{
for (unsigned long y=0;y<uFloats.size();y++)
{
mat1[x][y]=0;
}
}
Does anybody see my error?
Thank you.
mat[x][y]instead ofmat[y][x]? - Taylor Brandstettervectorsas inputs and return values, yet feel the need to manage memory dynamically instead of usingvectors internal to your function? - Zac Howland