Hello lost110,
It has been my experience that the C4715 has been a warning and not an error.
As a warning this will not stop the program from compiling or running, but does warn of a potential problem.
I have also found that it usually refers to the end of the function and not, with your case the if/else if statements.
That being said this should help:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
|
int Search(int v, int index)
{
if (index >= size)
return -1;
else if (v != arr[index])
{
if (v < arr[index])
Search(v, (2 * index) + 1);
else if (v > arr[index])
Search(v, (2 * index) + 2);
}
else if (v = arr[index])
return index;
// <--- Nothing returned here. What the warning is complaining about.
}
|
I did not have enough information to test the function like:
• Where is "arr" defined and how?
• What is "v" and what value does it have? "v" needs a better name.
• What value does "index" have when the function is first called?
The other part i will mention is that "=" means set and "==" means compare. Look closer at your code.
Andy