- Modern C++:Efficient and Scalable Application Development
- Richard Grimes Marius Bancila
- 113字
- 2021-06-10 18:28:04
Function body
After the return type, function name, and parameters have been determined, you then need to define the body of the function. The code for a function must appear between a pair of braces ({}). If the function returns a value, then the function must have at least one line (the last line in the function) with the return statement. This must return the appropriate type or a type that can be implicitly converted to the return type of the function. As mentioned before, if the function is declared as returning auto, then the compiler will deduce the return type. In this case, all the return statements must return the same type.