Early versions of C used a different parameter declaration method than does either
Standard C or Standard C++. This early approach is sometimes called the classic form.
This book uses a declaration approach called the modern form. Standard C supports
both forms, but strongly recommends the modern form. Standard C++ only supports
the modern parameter declaration method. However, you should know the old-style
form because many older C programs still use it.
The old-style function parameter declaration consists of two parts: a parameter
list, which goes inside the parentheses that follow the function name, and the actual
parameter declarations, which go between the closing parentheses and the function's
opening curly brace. The general form of the old-style parameter definition is
type func_name(parm1, parm2, . . .parmN)
type parm1;
type parm2;
.
..
type parmN;
{
function code
}
Standard C or Standard C++. This early approach is sometimes called the classic form.
This book uses a declaration approach called the modern form. Standard C supports
both forms, but strongly recommends the modern form. Standard C++ only supports
the modern parameter declaration method. However, you should know the old-style
form because many older C programs still use it.
The old-style function parameter declaration consists of two parts: a parameter
list, which goes inside the parentheses that follow the function name, and the actual
parameter declarations, which go between the closing parentheses and the function's
opening curly brace. The general form of the old-style parameter definition is
type func_name(parm1, parm2, . . .parmN)
type parm1;
type parm2;
.
..
type parmN;
{
function code
}
For example, this modern declaration:
float f(int a, int b, char ch)
{
/* ... */
}
will look like this in its old-style form:
float f(a, b, ch)
int a, b;
char ch;
{
/* ... */
}
Notice that the old-style form allows the declaration of more than one parameter in a
list after the type name.
The old-style form of parameter declaration is designated as obsolete by the C
language and is not supported by C++.
float f(int a, int b, char ch)
{
/* ... */
}
will look like this in its old-style form:
float f(a, b, ch)
int a, b;
char ch;
{
/* ... */
}
Notice that the old-style form allows the declaration of more than one parameter in a
list after the type name.
The old-style form of parameter declaration is designated as obsolete by the C
language and is not supported by C++.
No comments:
Post a Comment