Concept
How can the return value communicate errors when roots are passed by reference?
ComputerScienceOne / Quadratic Roots
"We also note that the return value in this case is unused since we are “returning” the root values in the two pass-by-reference variables. This frees up the return value to be used to communicate errors to the calling function. Recall that there could be several “bad” inputs to this function. The roots could be complex values, the coefficient a could be zero, etc. And now that we are dealing with pointers, the pointers could be invalid (point to NULL). In the next chapter, we examine how we can use the return value to communicate different errors to the calling function, letting it handle those errors."
Related Ideas
- How can a quadratic roots function return error codes?ComputerScienceOne · Error Handling By Design
- How can enumerated types be used for error codes in C?ComputerScienceOne · Using Enumerated Types for Error Codes
- How can PHP pass variables by reference to return multiple quadratic roots?ComputerScienceOne · Quadratic Roots
- How can pointers be used to pass variables by reference?ComputerScienceOne · Passing By Reference
- How can you check for a NULL pointer and dereference a valid pointer?ComputerScienceOne · Passing By Reference
- How can conditionals handle invalid inputs and special cases in a quadratic roots program?ComputerScienceOne · Quadratic Roots Revisited
- How does the Java quadratic roots program check errors and calculate its roots?ComputerScienceOne · Quadratic Roots Revisited
- What kinds of user input can cause problems in a quadratic-roots program?ComputerScienceOne · Computing Quadratic Roots