title: Standard way to pass struct to a header file
body: <p>I would like to know the standard/correct way to pass a <code>struct</code> declared in <code>main.cpp</code> to a class header file, where I want to alter the content of that structure in the header file. The following is a simple example of what I want to do, and it works correctly. However, I wanted to know if there is a better, more standard way to do it. I'm not too adept in C++ so I'm not sure if my current implementation has hidden flaws.</p>
  
  <p>num.h</p>
  
  <pre><code>struct A {
      int x, y;
  };
  
  class Num {
      public:
          void change(struct A&amp; s, int t){
              s.x = t;
          }
          int getNum(int b){
              return b;
          }
  };
  </code></pre>
  
  <p>main.cpp</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include "num.h"
  using namespace std;
  
  int main(){
      Num n;
      A a;
      a.x = 8;
      a.y = 9;
  
      cout &lt;&lt; n.getNum(a.x) &lt;&lt; endl;  \\outputs 8
      n.change(a, 5);
      cout &lt;&lt; n.getNum(a.x) &lt;&lt; endl;  \\outouts 5
  
      return 0;
  }
  </code></pre>
  
  <p>Essentially, I want to have the structure <code>A</code> visible to both the <code>.cpp</code> and the <code>.h</code> file so both can alter it. Currently, my solution was to declare <code>struct A</code> at the top of the header file since the header file is like the extension of the <code>.cpp</code> file so it is as if I had declared <code>struct A</code> at the very beginning of all my code--visible to everything. I'm not sure if this is the best way though. I would appreciate some feedback.</p>