2013-10-18 64 views
-3

我有以下的cpp文件,并错误“宣言预计”在此行中被抛出,在“为”指点:C++:错误“申报预期”

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. 

} 

有没有人看到我出错的地方?

+1

你有一些错别字:缺少分号,'iNumClass'而不是'uNumClass'。你能复制粘贴你真正想要编译的东西吗? – lolando

+0

有几行错误,但不是那一行。也许你可以发布你正在编译的确切代码,以及确切的错误消息? –

+0

这个问题是非常基本的,但这不能保证-5票。以代码为例,他已经清楚地表达了这个问题,并努力尝试自己解决它(如底部的评论所示)。 +1取消一些反对票。 – JBentley

回答

4

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

vector<float>m_Floats; 
2

可能的错字,

mat1[i] = new float[iNumClass]; 

应该

mat1[i] = new float[uNumClass]; 
9

有你指示行没有错误。错误是:

  • 在第7行末尾丢失分号(声明m_Floats)。
  • 失踪的iNumClassuNumClass声明(大概是他们在头你还没有告诉我们)
  • 逗号,而不是第20行的分号,for循环递增器前。