|
Authored by: BitOBear on Saturday, April 21 2012 @ 07:14 PM EDT |
Just to be picky...
This is a declaration:
int increment(int X);
It reads "there exists a function called increment that takes a single
integer argument and returns an integer result"; The name of the argument
is immateral and optional in this usage.
This is a definition:
int increment(int X) { return X + 1; }
It is the definition -because- it has the braces and code. It defines the
function. It is -wrong- in terms-of-art for programming to call "the part
before the braces" the definition of the function. The part before the
braces declares the function. This declaration may or may not repeat a stand
alone declaration.
More concisely the "definition" of a function is the code that
comprises that function. It "defines" the function. Absent the code
the function is not defined and can not be executed.
Declarations can be repeated as often as you want, and typically occur at least
twice. Once where you need it in the using code, and once as the start of the
definition.
[ Reply to This | Parent | # ]
|
|
|
|
|