Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

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.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>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.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading