Zee Shan
Zee Shan

Reputation: 1

Argument name in function prototype

AS in function decleration, three things are required i.e. Return value type. Function name. (argument type). but argument name is not necessary. Then why this program generates an error, when i remove the argument name ( arr[][maxCols] ) from the function prototype (void readMatrix(int arr[][maxCols] );)

In simple words.

void readMatrix(int arr[][maxCols] );    // fine and no error.

void readMatrix(int);                    // but this generates error when argument name is not mentioned in function prototype.

Upvotes: 0

Views: 100

Answers (1)

Christian Hackl
Christian Hackl

Reputation: 27538

Because [][maxCols] does not belong to the name but to the type.

For a declaration without a name, write:

void f(int [][maxCols])

And raw arrays are usually a poor choice. Use std::vector or std::array.

Upvotes: 7

Related Questions