title: [error]taking address of temporary array in C++?
body: <p>I have a function in java </p>
  
  <pre><code>static int a2(int[] a)
  {
  int sumEven = 0;
  int sumOdd = 0;
  
  for (int i=0; i&lt;a.length; i++)
  {
    if (a[i]%2 == 0)
      sumEven += a[i];
    else
      sumOdd += a[i];
  }
  
  return sumOdd - sumEven;
  }
  </code></pre>
  
  <p>I am calling it from main in java like</p>
  
  <pre><code>public static void main()
  {
  a2(new int[] {1});
  a2(new int[] {1, 2});
  a2(new int[] {1, 2, 3});
  a2(new int[] {1, 2, 3, 4});
  a2(new int[] {3, 3, 4, 4});
  a2(new int[] {3, 2, 3, 4});
  a2(new int[] {4, 1, 2, 3});
  a2(new int[] {1, 1});
  a2(new int[] {});
  }
  </code></pre>
  
  <p>Where a2 is function and argument is array.
  This same thing I want to achieve in c++ but I can't pass array to function like I passed in java. It is giving error [error]taking address of temporary array. </p>
  
  <p>In c++, I am doing like that </p>
  
  <pre><code>f((int[4]) {1,2,3,4});
  </code></pre>
  
  <p>Giving error => [error]taking address of temporary array.</p>
  
  <p>How to achieve this?</p>