What does “warning: not all control paths return a value” mean? (C++)

前端 未结 7 1293
梦谈多话
梦谈多话 2020-12-20 07:18

The exact warning I get is

warning C4715: \'hand::show\' : not all control paths return a value

and hand::show is

std::ostr         


        
7条回答
  •  情深已故
    2020-12-20 07:55

    Your compiler isn't smart enough to take into account that the only two options for side are left and right, so it thinks it's possible for neither return statement to be executed. When side is neither left nor right, your function doesn't say which value to return.

提交回复
热议问题