Function prototyping

  • A function prototype is a function declaration that specifies the data types of its arguments in the parameter list.
  •  a function prototype or function interface is a declaration of a function that specifies the function's name and type signature (arity, parametertypes, and return type), but omits the function body.
  • Prototypes are syntactically distinguished from the old style of function declaration.
  • While a function definition specifies how the function does what it does (the "implementation"), a function prototype merely specifies its interface, i.e. what data types go in and come out of it.
  • 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.
  • The two styles can be mixed for any single function, but this is not recommended. The following is a comparison of the old and the prototype styles of declaration:

Old style:

  • Functions can be declared implicitly by their appearance in a call.
  • Arguments to functions undergo the default conversions before the call.
  • The number and type of arguments are not checked.

Prototype style:

  • Functions are declared explicitly with a prototype before they are called.
  • Multiple declarations must be compatible, parameter types must agree exactly.
  • Arguments to functions are converted to the declared types of the parameters.
  • Empty parameter lists are designated using the void keyword.
  • Ellipses are used in the parameter list of a prototype to indicate that a variable number of parameters are expected.

Subscribe us on Youtube

Share This Page on


Abhigna | 17-Mar-2018 08:49:24 am

are you created on operator overloading page?

Ask Question