title: Passing an array of structs by reference in C++
body: <p>So I'm still rather new to programming/C++, and still trying to wrap my head around pointers and passing by reference and everything. A program I'm trying to figure out now needs to pass an array of structs to another function. I've gotten it working by just passing the array directly there. It seems to work fine. However, what I'm concerned about is that I believe I'm passing it by value, and I understand that it's better to pass structs by reference, so you're not making a copy of the struct every time...</p>
  
  <p>Anyway, here's a basic example of what I'm doing:</p>
  
  <pre><code>struct GoldenHelmet {
      int foo;
      string bar;
      };
  
  void pass (GoldenHelmet ofMambrino[], int size);
  
  int main () {
      GoldenHelmet ofMambrino[10];
      int size = sizeof(ofMambrino) / sizeof(ofMambrino[0]);
      ofMambrino[1].foo = 1;
      pass(ofMambrino, size);
      cout &lt;&lt; ofMambrino[2].foo &lt;&lt; endl;
      return 0;
  }
  
  void pass (GoldenHelmet ofMambrino[], int size) {
      ofMambrino[2].foo = 100;
      ofMambrino[2].bar = "Blargh";
  }
  </code></pre>
  
  <p>From what I understand, it works because arrays are already pointers, right? But the way I have that configured, am I still passing a copy of the struct and everything to the pass() function? I've tried to pass it by reference, but it doesn't seem to want to work any way I've tried.</p>