2015-10-19 63 views
0

代码C++,VS2005请帮我解决这个编译错误

BOOL CGrAllObjects::ReorderObj(CGrObject* pGrFind,int ixObjNewIx) 
    { 

     int nSubCode,nLyrCode=pGrFind->GetLayerCode(nSubCode); 
     CGrObject* pGrObject; 
     CGrObjectArray* 
     pGrObjectArray=GetObjArrayFromCode(nLyrCode,nSubCode); 

     if(!pGrObjectArray) return FALSE; 

     for(int ixObj=pGrObjectArray->GetSize()-1; ixObj>=0; ixObj--) 

     {  pGrObject=pGrObjectArray->GetAt(ixObj); 

       if(pGrObject==pGrFind) break; 

     } 

     if(ixObj<0) return FALSE; 

     if(ixObj!=ixObjNewIx) 

     {  pGrObjectArray->RemoveAt(ixObj); 

       pGrObjectArray->InsertAt(ixObjNewIx,pGrFind); 
     } 

     return TRUE; 
} 






Error: 1>c:\xxx\xxx\xxxx\xxxx\xxxx\xxxxx\xxxx.cpp(359) : error C2065: 
'ixObj' : undeclared identifier 

回答

0

for(int ixObj ...变量“ixObj”在for循环的范围只被定义,不知道外面。

循环之前定义的整数,并从 '为' 的decalration:

int ixObj; 
for(ixObj=... 
+0

感谢迈克尔。有效。 – Rohit