C++:错误"声明预期"

tmi*_*hty -3 c++ for-loop

我有以下cpp文件,并在此行中抛出错误"Declaration expected",指向"for":

for (int i = 0; i < m_Floats.size(); ++i) 
Run Code Online (Sandbox Code Playgroud)

整个代码是:

#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.

}
Run Code Online (Sandbox Code Playgroud)

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

Mik*_*our 9

您指明的行没有错误.错误是:

  • 第7行末尾缺少分号(声明m_Floats).
  • 缺少声明iNumClassuNumClass(可能是他们在你没有向我们展示的标题中)
  • 在for-loop增量器之前,在第20行上使用逗号而不是分号.