title: Pass-by-value-Result?
body: <blockquote>
  <p><strong>Possible Duplicates:</strong><br />
  <a href="https://stackoverflow.com/questions/2027/pass-by-reference-or-pass-by-value">pass by reference or pass by value?</a></p>
  </blockquote>
  
  <p>I'm having difficulty understanding the <strong>Pass-by-Value-Result</strong> method. I understand <em>Pass-by-Reference</em> and <em>Pass-by-Value</em>, but I'm not quite clear on <em>Pass-by-Value-Result</em>. How similar is it to <em>Pass-by-Value</em> (assuming it is similar)?</p>
  <p>Here is the code</p>
  <pre><code>#include &lt;iostream&gt;
  #include &lt;string.h&gt;
  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 &lt;&lt; value &lt;&lt; &quot;   &quot; &lt;&lt; list[0] &lt;&lt; endl;
  
    swap(list[0], list[1]);
  
    cout &lt;&lt; list[0] &lt;&lt; &quot;   &quot; &lt;&lt; list[1] &lt;&lt; endl;
  
    swap(value, list[value]);
  
    cout &lt;&lt; value &lt;&lt; &quot;   &quot; &lt;&lt; list[value] &lt;&lt; endl;
  
  }
  </code></pre>
  <p>The objective is to determine the values of <code>value</code> and <code>list</code> if the <em>Pass-by-Value-Result</em> method is used. (<em>NOT Pass-by-Value</em>).</p>