C++ function

Feb 15, 2011 at 9:04am
Hi
I would like to know why we do not define function parameter inside the function itself and why we are allowed to used them?
Feb 15, 2011 at 11:56am
Function parameters are information passed into the function.

1
2
3
4
int Function (int a0, int a1)
{
return a0 + a1;
}


That code would create a function in the computer's memory. When we call the function:

 
Function (t0, 45);


It will make a copy of the values in the variables passed in, and set the value of a0 with the value of t0, and the value of a1 with the value 45. Then the function will return the two values added.

So basically arguments/parameters (Same thing) are information passed into the function, for the function to do its job.

This clear things up?
Topic archived. No new replies allowed.