General Question About Classes

I have a general question about classes. Suppose we have the following function declaration in a header file:
 
some_function(double, double);


Similarly, suppose we define the function in its corresponding cpp file:

1
2
3
4
5
some_class::some_function(double variable1, double variable2)

{
    // do stuff on variable1 and variable2
}


I have seen functions be declared in the above format. But, I have also seen functions declared in the following format in the header file:

 
some_function(double variable1, double variable2);


So, my question is... Are the two function declarations in the header file equivalent? If not, then why do we sometimes include the variable names in the function declaration, and sometimes not? Thanks!
You can leave out the parameter name in both declaration and definition if you want.

Often the parameter names say something about the parameter so it can be worth having it there for readability. I guess another reason is that people are lazy and just copy paste the function header so it is simpler to just use the same as in the definition.

In the definition you want to have the parameter names because otherwise you can't use the parameters in the function.
So, let me see if I understand...

If I want to use variable1 and variable2 in the function definition (i.e., in the cpp file), then I obviously need to write them in the function's argument list (i.e., in between the parentheses). However, I can leave them out in the function declaration in the header file if I want.

Is this correct?
yes
Topic archived. No new replies allowed.