title: C++ pass struct from from one class to another class
body: <p>I have two classes A and B defined in A.h, A.cpp and B.h, B.cpp respectively. Class A has a structure that I want to use in a function of Class B. Because Class B is included in Class A, I can't  include class A in Class B as it will lead to circular dependency. Code for all the files are given below:
  A.h</p>
  
  <pre><code>#ifndef _A_H
  #define _A_H
  #include B.h
  namespace common {
      class A {
      public:
          static struct strctOfA {
             float p1 = 2;
          } structA;
          void functionOfA();
      };
  }
  #endif // !_A_H
  </code></pre>
  
  <p>A.cpp</p>
  
  <pre><code>#include A.h
  using namespace common;
  A::functionOfA() {
      B b;
      b.functionOfB(structA);
  }
  </code></pre>
  
  <p>B.h</p>
  
  <pre><code>#ifndef _B_H
  #define _B_H
  namespace common {
      class B {
      public:
           functionOfB(??);
      };
  }
  #endif // !_B_H
  </code></pre>
  
  <p>B.cpp</p>
  
  <pre><code>#include B.h
  using namespace common;
  B::functionOfB(??) {
          // Want to use structA here;        
  }
  </code></pre>
  
  <p>I looked into StackOverflow and found a <a href="https://stackoverflow.com/questions/29564322/pass-a-c-struct-pointer-from-one-class-to-another-one">thread</a> quite close to my problem, however, they it either doesn't explains the answer or I am not able to understand their solution. Please help me with this.</p>
  
  <p>Thanks</p>
  
  <p><strong>Update</strong>
  Thanks I-V for pointing out the mistake and providing me the explanation. Updating the code worked for me. Thanks everyone for providing additional knowledge to my C/C++ coding skills. :)</p>