Professional Documents
Culture Documents
Viva
Viva
In a prototype, parameter names are optional (and in C/C++ have function prototype
scope, meaning their scope ends at the end of the prototype), however, the type is
necessary along with all modifiers (e.g. if it is a pointer or a const parameter).
In object-oriented programming, interfaces and abstract methods serve much the same
purpose.
Contents
1 Example
2 Uses
2.1 Creating library interfaces
2.2 Class declaration
3 See also
4 References
Example
Consider the following function prototype:
Uses
In earlier versions of C, if a function was not previously declared and its name
occurred in an expression followed by a left parenthesis, it was implicitly
declared as a function that returns an int and nothing was assumed about its
arguments. In this case the compiler would not be able to perform compile-time
checking of argument types and Syntax arity when the function was applied to some
arguments. This can cause problems. The following code illustrates a situation in
which the behavior of an implicitly declared function is undefined.
#include <stdio.h>
Class declaration
In C++, function prototypes are also used in class definitions.