float OverTime::getsalary() { if (hoursWork > 40) { hourlyRate += (hourlyRate /2); } else return hoursWork * hourlyRate; }
Problem with the above function is you have an else
clause you don't need. In the above, not all paths return a value because the return
statement is part of your else clause only, but the function expects you to return a float regardless of the logical paths.