I am so lost! I just need somebody to explain what to do and how it works.

There are generally two kinds of parameters to a function, those by VALUE and those by REFERENCE. A VALUE parameter is one where the variable's value (it's contents) are passed to the routine, whereas a REFERENCE parameter is one where the variable's location is passed to the routune.

Here's an example:

void Test( int byValue, int& byReference )
{
    byValue++;  // this changes the local version, but doesn't affect the caller
    byReference++;  // this changes the caller's variable too
    printf( "inside TEST value=%d, ref=%d\n", byValue, byReference );
        // this prints 2 for both since they were passed in as 1 in our call shown below...
}
...
    int byValue = 1, byReference = 1;
    Test( byValue, byReference );
    printf( "after TEST value=%d, ref=%d\n", byValue, byReference );
        // this prints 1 and 2, because Test() changed the byReference one but not the byValue one.
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.