title: Java  and C++ pass by value and pass by reference
body: <p>It is said that in Java method arguments are passed by value which is true for primitives and for objects, object's reference is passed by value. To illustrate consider the code:</p>
  
  <pre><code>class Test {
   private static void dateReplace (Date arg) {
          arg = new Date (arg.getYear(), arg.getMonth(), arg.getDate() +1);
          System.out.println ("arg in dateReplace: " + arg);
      }
  
   public static void main(String[] args) {
  
        Date d1 = new Date ("1 Apr 2010");
          dateReplace(d1);
          System.out.println ("d1 after calling dateReplace: " + d1);
      }
  }
  
  this will print:
  arg in dateReplace: Fri Apr 02 00:00:00 2010
  d1 after calling dateReplace: Thu Apr 01 00:00:00 2010.
  </code></pre>
  
  <p>What is the C++ equivalent that would give same results?</p>
  
  <p>What is C++ equivalent that would give the value of d1 after calling the method to be the same value as within the method i.e. the caller see the modified value? </p>