Current location - Plastic Surgery and Aesthetics Network - Plastic surgery and medical aesthetics - When declaring and defining a function, do I have to give the return value type of the function?
When declaring and defining a function, do I have to give the return value type of the function?

Not necessarily given explicitly.

If the return value type is not given, the default is integer.

For example:

fun(int x) { return x*x;} The default is integer

It is equivalent to you writing int fun(int x) { return x*x;}

Other types must be written, and those without return values ??must be written as void type.