What does “control reaches end of non-void function” mean?

后端 未结 7 1653
野的像风
野的像风 2020-11-28 11:24

I\'ve been getting strange compiler errors on this binary search algorithm. I get a warning that control reaches end of non-void function. What does this mean?<

7条回答
  •  -上瘾入骨i
    2020-11-28 11:43

    The compiler isn't smart enough to know that <, >, and == are a "complete set". You can let it know that by removing the condition "if(val == sorted[mid])" -- it's redundant. Jut say "else return mid;"

提交回复
热议问题