C++ - 함수 호출

return

  • return 문이 실행 될 때 함수가 제어를 호출측으로 되돌려주게 된다.

  • return cpp reference

Void functions are created and used just like value-returning functions except they do not return a value after the function executes. In lieu of a data type, void functions use the keyword “void.” A void function performs a task, and then control returns back to the caller–but, it does not return a value. You may or may not use the return statement, as there is no return value. Even without the return statement, control will return to the caller automatically at the end of the function. A good utilization of a void function would be to print a header/footer to a screen or file.

  • need for an explicit return at the end of the function. return; is optional code at the end of the funtion

Categories:

Updated: