It looks to me like you want to return TRUE if start and tracking are both the same (be it both TRUE or both FALSE). Note that your function claims to return an int, but you actually return a bool.
This code shows the logic of it.
1 2 3 4 5 6 7 8 9 10 11 12 13
|
bool function(bool start, bool tracking)
{
bool execute;
if (start == tracking)
{
execute = TRUE;
}
else
{
execute = FALSE;
}
return execute;
}
|
This code does the same thing, with a bit more elegance.
1 2 3 4 5 6 7
|
bool function(bool start, bool tracking)
{
bool returnVal;
(start == tracking) ? returnVal = true : returnVal = false ;
return returnVal;
}
|
Of course, this lends itself to the following evolution:
1 2 3 4
|
bool function(bool start, bool tracking)
{
return (start==tracking);
}
|
At which point you realise that you don't need a function at all, you can just do what you were first trying to do in your original code, without even needing a separate function. In the code that calls this function, remove calls to the function and just use
execute = (start == tracking);
You were just missing some brackets.
Hope this makes everything nice and clear.
Disclaimer: I very rarely use
bool type, and when I do I carry an assumption that the integer zero will be silently cast to
false, and any other integer value to
true. This assumption may well be in my code above.