0
What is the need of return value in c or cpp?
I can't understand the concept of the return value.
1 Réponse
+ 4
A function may be designed to return something to the caller (or not at all). The something could be a simple math calculation result to a complex object created and initialized in the function. It all depends on needs.
The `return` statement is used to (duh) return that something to the caller (in case the function was designed to return some type); the use of `return` in a function that wasn't designed to return anything means that the execution point must leave the function prematurely, leave the rest of statements without executing them, and return to the last execution point - which most likely be somewhere in its caller block where the function was invoked..