Function return type specifiers
The result of a function is called its return value and the data type of the return value is called the return type.
Every
function declaration and definition must specify a return type, whether
or not it actually returns a value.
If
a function declaration does not specify a return type, the compiler
assumes an implicit return type of int. However,
for conformance to C99, you should specify a return type for every
function declaration and definition, whether or not the function returns int.
A function may be defined to return any type of value, except an
array type or a function type; these exclusions must be handled by
returning a pointer to the array or function. When a function does
not return a value, void is the type specifier in
the function declaration and definition.
A function cannot be declared as returning a data object having
a volatile or const type, but it
can return a pointer to a volatile or const object.
enum count {one, two, three};
enum count counter();
The
user-defined type may also be defined within the function declaration.
The
user-defined type may not be defined within the function declaration. enum count{one, two, three} counter(); // legal in C
enum count{one, two, three} counter(); // error in C++
References can also be used as return types for functions.
The reference returns the lvalue of the object to which it refers.