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

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

    To get rid of the warning, replace the second if with an else:

    std::ostream& hand::show(std::ostream& os) const
    {
        if(side == left)
        {
            return os<

提交回复
热议问题