title: How to access an element of an std::array given its pointer in C++
body: <p>I'm trying to access an element of an <code>std::array</code> given its pointer in C++. Here's some code that illustrates my problem:</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;array&gt;
  
  void func(std::array&lt;int, 4&gt; *);
  
  int main()
  {
      std::array&lt;int, 4&gt; arr = {1, 0, 5, 0};
      func(&amp;arr);
  }
  
  void func(std::array&lt;int, 4&gt; *elements)
  {
      for (int i = 0; i &lt; 4; i = i + 1)
      {
          std::cout &lt;&lt; *elements[i] &lt;&lt; std::endl;
      }
  }
  </code></pre>
  
  <p>I would expect this to print every element of the <code>std::array</code> on a new line. However, it doesn't even get past compiling:</p>
  
  <pre><code>main.cpp: In function ‘void func(std::array&lt;int, 4ul&gt;*)’:
  main.cpp:16:22: error: no match for ‘operator*’ (operand type is ‘std::array&lt;int, 4ul&gt;’)
           std::cout &lt;&lt; *elements[i] &lt;&lt; std::endl;
  </code></pre>
  
  <p>What's going on here?<br>
  Thanks! </p>