Possible Duplicates:
pass by reference or pass by value?
I'm having difficulty understanding the Pass-by-Value-Result method. I understand Pass-by-Reference and Pass-by-Value, but I'm not quite clear on Pass-by-Value-Result. How similar is it to Pass-by-Value (assuming it is similar)?
Here is the code
#include <iostream>
#include <string.h>
using namespace std;
void swap(int a, int b)
{
  int temp;
    temp = a;
    a = b;
    b = temp;
}
int main()
{
  int value = 2;
  int  list[5] = {1, 3, 5, 7, 9};
  swap(value, list[0]);
  cout << value << "   " << list[0] << endl;
  swap(list[0], list[1]);
  cout << list[0] << "   " << list[1] << endl;
  swap(value, list[value]);
  cout << value << "   " << list[value] << endl;
}
The objective is to determine the values of value and list if the Pass-by-Value-Result method is used. (NOT Pass-by-Value).
 
     
     
    