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

前端 未结 7 1282
梦谈多话
梦谈多话 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 08:08

    As others suggest, the problem is that your side might be neither left nor right.
    You may modify your function to do any of the following:

    1. change the second if statement to an else, or remove the condition all together, since if the side is not left, it must be right.
    2. follow Nathaniel Flath's suggestion and modify the orientation type to an enum.
    3. raise an exception as the last statement of the function.
    0 讨论(0)
提交回复
热议问题