title: Using a struct across classes in c++
body: <p>I am still fairly new to c++ so please allow!
  Essentially I have created a struct in the header file for one of my classes full of strings.</p>
  
  <pre><code>typedef struct details{
          string name;
          string address;
  }details;
  </code></pre>
  
  <p>and I wish to not only use this struct in the cpp file that belongs to the header, but in other classes as well. For example, I want to create a vector of this struct in another header file. </p>
  
  <pre><code>private:
  vector &lt;details&gt; foo;
  </code></pre>
  
  <p>I also want to use the struct in the main</p>
  
  <pre><code>details d;
  d.name = "hi";
  d.address = "hello";
  </code></pre>
  
  <p>however when I currently try to do this I get errors such as </p>
  
  <pre><code>error: 'details' was not declared in this scope
       vector &lt;details&gt; foo;
  </code></pre>
  
  <p>and</p>
  
  <pre><code>error: template argument 1 is invalid
       vector &lt;details&gt; foo;
  </code></pre>
  
  <p>has anyone had similar issues who can provide insite into what I can do to fix this? Thanks a lot.</p>
  
  <p><strong>EDIT TO DEMONSTRATE CODE</strong></p>
  
  <p>class1.h</p>
  
  <pre><code>#include "class2.h"
  
  struct trans1{
      string name;
  };
  class class1 {
  
  private:
      vector &lt;trans2&gt; t2;
  
  public:
      class1();
  };
  </code></pre>
  
  <p>class2.h</p>
  
  <pre><code>#include "class1.h"
  
  struct trans2{
      string type;
  };
  
  class class2{
  
  private:
      vector &lt;trans1&gt; t1;
  
  public:
      class2();
  };
  </code></pre>
  
  <p>errorlog:</p>
  
  <pre><code>In file included from class1.h:3:0,
                   from class1.cpp:1:
  class2.h:21:13: error: 'trans1' was not declared in this scope
       vector &lt;trans1&gt; t1;
               ^
  class2.h:21:19: error: template argument 1 is invalid
       vector &lt;trans1&gt; t1;
                     ^
  class2.h:21:19: error: template argument 2 is invalid
  </code></pre>
  
  <p>I understand that this is ridiculous code in a real world application however this is the simplest way I could demonstrate</p>