当前位置:首页
开发技术指南» 文章正文
    引言:
 

 

 ·如何判断一个字符是不是汉字    »显示摘要«
    摘要: 如何判断一个字符是不是汉字? ......
 ·运行中出现的问题,困惑    »显示摘要«
    摘要: 好几次,我编写的几个小程序,当运行时总出现expected=but(found.的一个对话框,到底哪错了,我真是找不出,大哥们,能帮的来呀! ......


HELP--->各位大哥快帮我看看,错在什么地方在线等待

小弟定义个函数  
  编译时报错:error   C2664:   is_right   :   cannot   convert   parameter   1   from   int   to   const   int   []  
  我就看不出哪里有类型转换  
                                              ………  
  Fraction   Math24_showall::jisuan(Fraction   opc1,int   op,Fraction   opc2)  
  {  
  switch(op)  
  {  
  case   1:  
  opc1+=opc2;  
  break;  
  case   2:  
  opc1-=opc2;  
  break;  
  case   4:  
  opc1*=opc2;  
  break;  
  case   5:  
  opc1/=opc2;  
  break;  
  };  
  return   opc1;  
  }  
   
  bool   Math24_showall::is_right(const   int   op[3],Fraction   opc[4],int   type)  
  {  
  bool   equal24=0;  
  switch   (type)  
  {  
  case   1:   //(a   op0   b)   op1   (c   op2   d)  
  if   (jisuan(jisuan(opc[0],op[0],opc[1]),op[1],jisuan(opc[2],op[2],opc[3]))==24)   equal24=1;  
  break;  
  case   2:   //((a   op0   b)   op1   c)   op2   d  
  if   (jisuan(jisuan(jisuan(opc[0],op[0],opc[1]),op[1],opc[2]),op[2],opc[3])==24)   equal24=1;  
  break;  
  case   3:   //(a   op0   (b   op1   c))   op2   d  
  if   (jisuan(jisuan(opc[0],op[0],jisuan(opc[1],op[1],opc[2])),op[2],opc[3])==24)   equal24=1;    
  break;  
  case   4:   //a   op0   ((b   op1   c)   op2   d)  
  if   (jisuan(opc[0],op[0],jisuan(jisuan(opc[1],op[1],opc[2]),op[2],opc[3]))==24)     equal24=1;  
  break;  
  case   5:   //a   op0   (b   op1   (c   op2   d))  
  if   (jisuan(opc[0],op[0],jisuan(opc[1],op[1],jisuan(opc[2],op[2],opc[3])))==24)     equal24=1;  
  break;  
  };  
  return   equal24;  
  }  
   
  void   Math24_showall::getString(const   int   op[3],const   Fraction   opc[4],int   type,buffer*   buf)  
  {  
  ……  
  if   (is_right(op[3],opc[4],type))//-->报错的地方  
   
                                      …………………  
 

NO.1   作者: point_to

if   (is_right(op[3],opc[4],type))//-->报错的地方  
  这里的op[3]是一个数不是数组  
  like     this:  
  void   fn(   a[4],...)  
  int   a[4];  
  fn(a[4],...)//error!!  
   
   
  is_right的第二个参数也是同样的问题!!  
 

NO.2   作者: devzhao

bool   Math24_showall::is_right(const   int   op[3],Fraction   opc[4],int   type)  
  前两个参数为指针  
   
  if   (is_right(op[3],opc[4],type))//-->报错的地方  
  这里前两个参数为int  
 

NO.3   作者: shishiXP

op[3]是int  
  const   int   op[3]是const   int   *  
   
  当然不行  
   
  可以用is_right(op,opc,type)

NO.4   作者: lbaby

参数类型不匹配  
   
  bool   Math24_showall::is_right(const   int   op[3],Fraction   opc[4],int   type)  
  事实上定义了等同于这样的函数:  
  bool   Math24_showall::is_right(const   int   *,Fraction   *,int   type)  
   
  当数组作为参数传递递时,退化为指针  
   
   
 

NO.5   作者: michaelli

在参数传递的过程中,你最好用指针来完成,你可以将if   (is_right(op[3],opc[4],type))//中的数组改为指针,应该就不会报错了。


 ·这段代码第5行错在哪里    »显示摘要«
    摘要: <script language=javascript> document.write("<marquee scrollamount=1 scrolldelay=30 direction= up width=350 height=110 id=news height=60 onmouseover=news.stop() onmouseout=news.start......
» 本期热门文章:

©2000-2007 All Rights Reserved. 最佳浏览:1024X768 MSIE