Apologies for the delayed response.
science man wrote: |
---|
So why does it require there to be at least two arguments? |
It requires 2 arguments because the prototype says so. See:
void showvalues(int [], int);
This is your prototype. The parameter list (between the parentheses) clearly indicates that this function requires 2 arguments to be passed to it when called; an
int*/int and an
int.
science man wrote: |
---|
Also, can you refresh me on what it means in programming terms to have an argument? |
An argument, not a quarrel, is a piece of data you give to a function when you call it. For instance:
1 2 3 4 5 6
|
void Function(int X);
int main()
{
Function(10);
}
|
In the above code, when
::Function() is called, 10 was passed to it. In this context, 10 is an argument.
science man wrote: |
---|
what's the difference betweeen passing by value v.s. reference? |
Passing-By-Value:
Passing-by-value generates a copy of the argument. Any changes made to the argument will not affect the original argument. For instance:
1 2 3 4 5 6 7 8 9 10 11 12
|
void Function(int X);
int main()
{
int A(10);
Function(A);
}
void Function(int X)
{
X = 0;
}
|
In this example,
A is passed to
::Function() by value. The value of
A is copied into the
X parameter of
::Function().
X is not bound to
A in anyway. Therefore, modifications to
X do not affect
A.
Passing-By-Reference
Passing by reference means you'll be working with the original argument. A reference parameter is bound to the argument that is passed to it. For instance:
1 2 3 4 5 6 7 8 9 10 11 12
|
void Function(int &X);
int main()
{
int A(10);
Function(A);
}
void Funtion(int &X)
{
X = 0;
}
|
In this example, when
A is passed to
::Function(),
X,
::Function()'s parameter, is bound to
A. As a result, modifications to
X affect
A, because
X is referring to
A (
X is bound to
A). Note that the object a references refers to is called a
referent.
Wazzak