读书人

函数没有返回值,该怎么解决

发布时间: 2013-01-27 13:56:15 作者: rapoo

函数没有返回值
代码如下,尽管编译通过,但编译时提示应当有返回值,是何原因?

C/C++ code
bool TAdaptiveDem::Cal_Dif_Slope(TGrid3D &Grid3D,TLidar &Lidar,int I,int J,int ID,int winsize,double max_slope)//判断点id与其周围格网的点的坡度差//I,J--grid 行 列号, ID 待定点ID,  winsize-邻居格网扫描窗口大小{ double px=Lidar.x[ID]; double py=Lidar.y[ID]; double pz=Lidar.z[ID]; vector <int> GrdPntIndex; //某格网内的的点ID索引; for(int i=I-1;i<=I+1;i++)   for(int j=I-1;j<=J+1;j++)    {      if(Grid3D.Find3DIndex(i,j,0,GrdPntIndex))     //若该格网有点,则进坡度判断         {                    int SumPnt=GrdPntIndex.size(); //格网内点总个数                    double x,y,z,slope;                    for(int k=0;k!=SumPnt;k++)                        {                          int id=GrdPntIndex[k];                          x=Lidar.x[id];                          y=Lidar.y[id];                          z=Lidar.z[id];                          slope=fabs(pz-z)/sqrt((px-x)*(px-x)+(py-y)*(py-y));      //判断邻居点坡度值                          if(slope>max_slope) return 0;                        } //for(int k=0;k!=SumPnt;k++)               }  //end if(Grid3D.Find3DIndex(i,j,0,GrdPntIndex))     //若该格网有点,则进行种子点判断      else return 0; //若是周围没有9个邻居格网,可能为孤点,也舍弃     }    //end for(int j=I-1;j<=J+1;j++)}


[解决办法]
你不是所有分支都有返回值,而函数要求有一个bool返回值

读书人网 >C++

热点推荐