title: Iterating through array of object pointers in C++ the old way (without range-based for)?
body: <p>I'm not really versed in C++, but I came to the following code:</p>
  
  <pre><code>BaseManager* allManagers[] =
  {
      mColorManager,
      mToolManager,
      mLayerManager,
      mPlaybackManager,
      mViewManager
  };
  
  for ( BaseManager* pManager : allManagers )
  {
      pManager-&gt;setEditor( this );
      pManager-&gt;init();
  }
  </code></pre>
  
  <p>I use an <a href="https://stackoverflow.com/questions/14117918/range-for-loop-help-expected-initializer-before-token">older g++</a>, so I cannot use <code>-std=c++11</code>, and I have to use <code>-std=c++0x</code>. Looking at the "old-school" equivalent in <a href="https://stackoverflow.com/questions/16342285/error-expected-initializer-before-token/16342334#16342334">error: expected initializer before ‘:’ token</a>, I would have hoped the following would work:</p>
  
  <pre><code>for ( auto it = allManagers.begin(); it != allManagers.end(); ++it )
  {
      BaseManager* pManager = *it;
      pManager-&gt;setEditor( this );
      pManager-&gt;init();
  }
  </code></pre>
  
  <p>... but it fails with:</p>
  
  <pre><code>error: request for member ‘begin’ in ‘allManagers’, which is of non-class type ‘BaseManager* [5]’
  error: unable to deduce ‘auto’ from ‘&lt;expression error&gt;’
  </code></pre>
  
  <p>So I gathered, since this <code>allManagers</code> is apparently just a C array, it is not an object with methods (like <code>.begin</code>) - so in the end, I finally got that piece to compile with:</p>
  
  <pre><code>for ( int i=0 ; i&lt;5 ; i++ )
  {
      BaseManager* pManager = allManagers[i];
      pManager-&gt;setEditor( this );
      pManager-&gt;init();
  }
  </code></pre>
  
  <p>... however, that requires me to write in the array length manually, which I don't like. </p>
  
  <p>So, my question is: what would be the proper way to iterate through such an array of pointers without using a range-based for loop - but also, without having to explicitly enter the hardcoded array length?</p>