Question: Apologies if you have seen this question before however it has yet to be answered, essentially in my code I have two structs, defined in separate headers and used globally throughout the project. I simply wish to use both structs (which again, are defined in two separate headers) in other cpp files than just the ones that the header file belongs to.
Here is some sample code which I have tested: 

class1.h

```
    #include "class2.h"
    #include <vector>
    #include <string>

    struct trans1{
        string name;
    };
    class class1 {

    private:
        vector <trans2> t2;

    public:
        class1();
    };

```

class2.h

```
    #include "class1.h"
    #include <vector>
    #include <string>        

    struct trans2{
        string type;
    };

    class class2{

    private:
        vector <trans1> t1;

    public:
        class2();
    };

```

errorlog:

```
    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 <trans1> t1;
                 ^
    class2.h:21:19: error: template argument 1 is invalid
         vector <trans1> t1;
                       ^
    class2.h:21:19: error: template argument 2 is invalid

```

*I understand that this is ridiculous code in a real world application however this is the simplest way I could demonstrate.*

It is worth noting that if I simply comment out the declaration of vector t1 or t2 under 'private:' the code compiles without fail. It is just the fact I am using a second struct.

Any help anyone? Thanks.

Answer: 
Simply forward-declare the classes that will be used. Put all implementation code into a cpp file, not inline in the header.

Make the vector private. This way no file that includes the header can force code generation against an incomplete class.
If You were to do this in single .cpp file, the solution would be trivial:

```
   struct trans1 { ... };
   struct trans2 { ... };
   class class1 { ... };
   class class2 { .... };

```

Now you just need to rearrange the code to get this result in every translation unit. (the order of classes/structs in the file is important)