>Passing by value.
This is how C passes function arguments, the value of the argument is copied and placed in the variable supplied by the definition:
Code:
int a = 10;
f ( a ); /* The value, 10, is passed to f */
.
.
.
void f ( int var ) /* The value, 10, is given to var */
{
...
}
>Passing by reference.
Passing by reference is when you give the function not a copy of the value, but another name that is the same as the original object, a synonym if you will. So changing it changes the original. C does not have this feature, so I'll use C++:
Code:
int a = 10;
f ( a ); // A reference, a different name that effects a, is passed
.
.
.
void f ( int& var ) // var is a different variable, but it's the same as a
{
...
}
>Dereference.
Used for pointers, dereferencing is when you follow a pointer to the address at which it points and obtain the value at that location.
>Direct Reference.
C does not have this feature, so once again I'll use references from C++. Direct reference is when you have a variable of another name that can be taken as a synonym for the original, much like a typedef:
Code:
typedef int my_int; // my_int is now int, but int still exists
int& my_a = a; // my_a is now a, but a still exists
>Indirect Reference.
This is what C uses, pointers to an object are indirect references to that object. The manner in which C simulates passing by references is to pass the value of a pointer (the address of the original object) to a function, then that address is assigned to another pointer by value but when dereferenced, the original object can still be accessed.
-Prelude