Parameter types

In a function declaration, or prototype, the type of each parameter must be specified. C++ In the function definition, the type of each parameter must also be specified. C In the function definition, if the type of a parameter is not specified, it is assumed to be int.

A variable of a user-defined type may be declared in a parameter declaration, as in the following example, in which x is declared for the first time:

struct X { int i; };
void print(struct X x);

C only The user-defined type can also be defined within the parameter declaration. C++ The user-defined type can not be defined within the parameter declaration.

void print(struct X { int i; } x);   // legal in C
void print(struct X { int i; } x);   // error in C++


[ Top of Page | Previous Page | Next Page | Contents | Index ]