yutou's blog

请不要做浮躁的人,请热爱C++。
posts - 14, comments - 1, trackbacks - 0, articles - 0
  C++博客 :: 首页 :: 新随笔 :: 联系 :: 聚合  :: 管理

使用if遇到的一点问题

Posted on 2008-04-07 17:06 yutou 阅读(188) 评论(0)  编辑 收藏 引用 所属分类: Programming
在if else if 使用中出现的一点问题,编译器报出“在return的前面缺少 ';' ”

int compare( int shu_size ,const vector <int> &_vec )
{
  
int vec_size = int(_vec.size());

  
if( shu_size == vec_size ) return shu_size;
  
else if( shu_size < vec_size )  return shu_size;
  
else ( shu_size > vec_size )  return vec_size;
}


//更改后通过编译的代码
int compare( int shu_size ,const vector <int> &_vec )
{
    
int vec_size = int(_vec.size());
    
if( shu_size == vec_size ) vec_size = shu_size;
    
return vec_size;
}


只有注册用户登录后才能发表评论。
网站导航: 博客园   IT新闻   BlogJava   知识库   博问   管理