Function syntax clarification

I was told by one instructor that this is the correct way to code functions.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# include <iostream>

using namespace std;

//should this have the names e.g., (ifstream& inf, int size, int height)?
//I was taught that the declaration should ONLY have the types (int, char, etc)
void myFunction(ifstream&, int, int);    //declare function

int main {

//call function
myFunction(inf, size, height);

other code

return 0;

//*************************myFunction******************************************
//  Name:         myFunction
//  Description:  does something great
//QUESTION:  DO I NEED TO RENAME THE VARIABLES THAT ARE BEING PASSED HERE AS //SHOWN BELOW?
//  Parameters:   ifstream& inf, space catches size, tall catches height
//  Return:       none
//******************************************************************************
void myFunction(ifstream& inf, int space, int tall) {

function code here

}
Last edited on
You can put the names or not, it doesn't matter.
Personally I put the names there as it makes it easier to determine at a glance what the function does (and also because VC++ intellisense only looks at that for showing the function info).

I don't know what you mean by "rename" the variables. The parameter names are exclusive to that function; you can have variables in main called the same if you feel like it.
Topic archived. No new replies allowed.