title: foreach in C++ int array
body: <p>I am new to C++ and I am writing the following code.
  I needed to iterate over all the addons in my calling function - <code>testFunction</code>. I know this works in C#, but this code is not working. Can anyone please point out the right way to do it in C++? </p>
  
  <pre><code>#include "stdafx.h"
  #include &lt;iostream&gt;
  #include "resource.h"
  
  int testFunction(char* tester);
  int _tmain()
  {
      int mainProd=2;
      int Addons[]={7,8,9,10};
  
      testFunction(mainProd,Addons);
  
  
  }
  void testFunction(int mainProd,int addons[])
  {
      for(int x = 0 ; addons.length;++x) ---- Not working 
      {
          std::cout&lt;&lt; addons[x];
      }
  }
  </code></pre>
  
  <hr>
  
  <p>I tried to implement vector as below suggestions by you guys</p>
  
  <pre><code>#include "stdafx.h"
  #include &lt;iostream&gt;
  #include "resource.h"
  #include &lt;vector&gt;
  
  void testFunction(std::vector&lt;int&gt; addons);
  
  int _tmain(int argc, _TCHAR* argv[])
  {
  
      std::vector&lt;int&gt;  Addons ;
      for(int i = 0 ;i&lt;10;++i)
      {
          Addons.push_back(i);
      }
       testFunction(Addons);
  }
  
  void testFunction(std::vector&lt;int&gt; addons)
  {
      for(int i =0 ; i&lt;addons.size();++i)
      {
          std::cout&lt;&lt;addons.at(i);
      }
  }
  </code></pre>