Lecture 1 - Slide 27 : 34
Functions and parameters
Non-nestable functions
Parameters are value parameters - Call-by-value
Function basics
Named, statically typed
Void (returns nothing) or with a single return type
Functions cannot be nested in each other in ANSI C - C89
A non-standard
gcc
extension allows such nesting, however.
Parameters
Parameters are passed by value
Pointers passed as value parameter: "
Call-by-reference
"
Positional correspondence
There exists an "ugly" variable length parameter mechanism
Unspecified number of arguments:
int printf(const char* ...)
From C to C++
Overloaded functions: Several functions with the same name
Default arguments: Trailing parameters can be given default values in the formal parameter list
int f()
in C++ corresponds to
int f(void)
in C
Lambda expressions in C++11