warning C4715: not all control paths return a value c++

前端 未结 2 816
我寻月下人不归
我寻月下人不归 2021-01-29 11:39

i made two functions, one to find and return smallest key in a red - black tree and the other one returns a pointer to a particular node with that node\'s key as input.These fun

相关标签:
2条回答
  • 2021-01-29 11:52

    In if (ptr->left != NULL) you fail to return a value, as the compiler says. You need to return a value.

    0 讨论(0)
  • 2021-01-29 11:53

    In findsmallestprivate:

    If condition ptr->left != NULL holds, you do not return anything. You just run findsmallestprivate(ptr->left); and then exit, but don't return expected int.

    warning C4715: not all control paths return a value means that you have a function which may not return a value sometimes depending of its input.

    Your other problems are the same as with findsmallestprivate.

    In returnnodepri:

    In case of ptr->key < key or ptr->key > key you don't return expected Tree::node*. You run returnnodepri, but not return any value as a result.

    0 讨论(0)
提交回复
热议问题