Is there a reason to name parameters in forward declaration?

Say I have this:

// Forward Declaration of the sum()
void sum(int, int);

// Usage of the sum
void sum(int a, int b)
{
    // Body
}

It could also be done like this:

// Forward Declaration of the sum()
void sum(int a, int b);

// Usage of the sum
void sum(int a, int b)
{
    // Body
}

Is the latter version just a waste of space? I see it both ways.

>Solution :

No you don’t need to.

You could even rename your function to

void _(int, int);

(in both places of course). But then it’s harder to follow still. In other words the parameter and function names are important for readability. Given most program documentation appears in header files, and most forward declarations are in header files, it makes sense to include the function parameter names as used in the function definition.

Remember that program source code has two users. The compiler is one, the programmer is the other.

Leave a Reply