-3

我有以下 cpp 文件,并且在这一行中抛出错误“预期声明”,指向“for”:

for (int i = 0; i < m_Floats.size(); ++i) 

整个代码是:

#include "stdafx.h"
#include <vector>
#include "clsJenksBreaks.h"

using namespace std;

vector<float>m_Floats

vector<float>getJenksBreaks(const unsigned int uNumClass)
{
    //std::sort(m_Floats, m_Floats + size, std::greater<float>());

    float **mat1 = new float*[m_Floats.size()];
    for (int i = 0; i < m_Floats.size(); ++i) 
    {
        mat1[i] = new float[iNumClass];
    }
    for (unsigned long x=0;x<uNumClass+1;x++)
    {
        for (unsigned long y=0;y<m_Floats.size()+1,y++)
        {
            mat1[x][y]=0;
        }
    }

    //I have commented out the other code that is in this function, but the error still exists.

}

有人看到我哪里出错了吗?

4

3 回答 3

9

您指示的行没有错误。错误是:

  • 第 7 行末尾缺少分号(声明m_Floats)。
  • 缺少iNumClass和的声明uNumClass(可能它们在您没有向我们展示的标题中)
  • 逗号而不是第 20 行的分号,在 for 循环增量器之前。
于 2013-10-18T13:40:53.597 回答
4

声明后缺少分号m_floats。尝试:

vector<float>m_Floats;
于 2013-10-18T13:30:06.553 回答
2

可能的错别字,

 mat1[i] = new float[iNumClass];

应该

 mat1[i] = new float[uNumClass];
于 2013-10-18T13:33:32.053 回答