Defining a function - function prototypestype functionName( type argname [, type, ...] ) { // function body }Example: // define a function that adds two integers, returning their sum int add (int lhs, int rhs) { return lhs + rhs; } In C and C++, functions do not need to be defined before use--they only need to be declared. However, eventually the function must be defined so that it can link. If a function has been previously declared, it must be defined with the same return value and argument types (or a new overloaded function will be created), but the names of the parameters do not have to be the same. // declare the add function int add (int, int); // define the add function later int add (int lhs, int rhs) { return lhs + rhs; } Related articles Functions tutorial |