Namespaces
Variants
Views
Actions

return statement

From cppreference.com

Terminates current function and returns specified value to the caller function.

Contents

[edit] Syntax

return expression (1)
return (2)

[edit] Explanation

The first version evaluates the expression, terminates the current function and returns the result of the expression to the caller function. The resulting type of the expression must be convertible to function return type.

The second version terminates the current function. Only valid if the function return type is void.

[edit] Keywords

return

[edit] Example