Struct defined in header and included in two source codes is only defined in one
<p>I have a struct defined in a header file with three other files that <code>#include</code> that header file.  One is another header(queue.h) file that defines a very basic hash table and the other two are source codes where one is defining the functions from the hash table header(queue.cpp) and the other contains main(p2.cpp). </p>

<p>The problem that I'm having is that the struct seems to work fine in p2.cpp but in queue.h the compiler is telling me that the struct is undefined.</p>

<p>Here is p2.h containing the struct definition.</p>

<pre><code>#ifndef __P2_H__
#define __P2_H__

#define xCoor 0
#define yCoor 1

#include &lt;iostream&gt;
#include &lt;string&gt;
#include "queue.h"
#include "dlist.h"  //linked list which I know works and is not the problem


using namespace std;

struct spot {
    float key[2];
    string name, category;
};

#endif /* __P2_H__ */
</code></pre>

<p>I have queue.h included in this header so that I only have to include p2.h in p2.cpp.</p>

<p>Here is p2.cpp</p>

<pre><code>#include &lt;iostream&gt;
#include &lt;string&gt;
#include &lt;iomanip&gt;
#include "p2.h"
using namespace std;


int main () {

    cout &lt;&lt; fixed;
    cout &lt;&lt; setprecision (4);
    Queue hashTable;
    spot *spot1 = new spot;
    spot1-&gt;key[xCoor] = 42.2893;
    spot1-&gt;key[yCoor] = -83.7391;
    spot1-&gt;name = "NorthsideGrill";
    spot1-&gt;category = "restaurant";
    hashTable.insert(spot1);
    Dlist&lt;spot&gt; test = hashTable.find(42.2893, -83.7391);
    while (!test.isEmpty()) {
        spot *temp = test.removeFront();
        cout &lt;&lt; temp-&gt;key[xCoor] &lt;&lt; " " &lt;&lt; temp-&gt;key[yCoor] &lt;&lt; " " &lt;&lt; temp-&gt;name &lt;&lt; " " &lt;&lt; temp-&gt;category &lt;&lt; endl;
        delete temp;
    }
    return 0;
}
</code></pre>

<p>Places and item in the hash table and takes it back out.</p>

<p>Here is queue.h</p>

<pre><code>#ifndef __QUEUE_H__
#define __QUEUE_H__

#include &lt;iostream&gt;
#include &lt;string&gt;
#include "dlist.h"
#include "p2.h"
using namespace std;

class Queue {
    // OVERVIEW: contains a dynamic array of spaces.

 public:

    // Operational methods

    bool isEmpty();
    // EFFECTS: returns true if list is empy, false otherwise

    void insert(spot *o);
    // MODIFIES this
    // EFFECTS inserts o into the array

    Dlist&lt;spot&gt; find(float X, float Y);

    // Maintenance methods
    Queue();                                   // ctor
    ~Queue();                                  // dtor

 private:
    // A private type
    int numInserted;
    int maxElts;
    Dlist &lt;spot&gt;** queue;

    // Utility methods

    //Increases the size of the queue.
    void makeLarger();

    int hashFunc(float X, float Y, int modNum);

};


#endif /* __QUEUE_H__ */
</code></pre>

<p>Here is queue.cpp</p>

<pre><code>#include &lt;iostream&gt;
#include &lt;string&gt;
#include &lt;cstdlib&gt;
#include "queue.h"
using namespace std;

bool Queue::isEmpty() {
    return !numInserted;
}

void Queue::insert(spot *o) {
    if (numInserted &gt;= maxElts) {
        makeLarger();
    }
    int index = hashFunc(o-&gt;key[xCoor], o-&gt;key[yCoor], maxElts);
    queue[index] -&gt; insertFront(o);
}

Queue::Queue() {
    numInserted = 0;
    maxElts = 1000;
    queue = new Dlist&lt;spot&gt;*[maxElts];
    for (int i = 0; i &lt; maxElts; i++) {
        queue[i] = new Dlist&lt;spot&gt;;
    }
}

Queue::~Queue() {
    for (int i = 0; i &lt; maxElts; i++) {
        delete queue[i];
    }
    delete[] queue;
}

void Queue::makeLarger() {
    Dlist &lt;spot&gt;** temp = queue;
    queue = new Dlist &lt;spot&gt;*[maxElts*2];
    for (int i = 0; i &lt; maxElts*2; i++) {
        queue[i] = new Dlist&lt;spot&gt;;
    }
    for (int i = 0; i &lt; maxElts; i++) {
        while (!temp[i] -&gt; isEmpty()) {
            spot *spotTemp = temp[i] -&gt; removeFront();
            int index = hashFunc(spotTemp-&gt;key[xCoor], spotTemp-&gt;key[yCoor], maxElts*2);
            queue[index] -&gt; insertFront(spotTemp);
        }
    }
    for (int i = 0; i &lt; maxElts; i++) {
        delete temp[i];
    }
    delete[] temp;
    maxElts *= 2;
}

int Queue::hashFunc(float X, float Y, int modNum) {
    return ((int)(10000*X) + (int)(10000*Y))%modNum;
}

Dlist&lt;spot&gt; Queue::find(float X, float Y) {
    Dlist&lt;spot&gt; result;
    Dlist&lt;spot&gt; *temp = new Dlist&lt;spot&gt;;
    int index = hashFunc(X, Y, maxElts);
    while (!queue[index] -&gt; isEmpty()) {
        spot *curSpot = queue[index] -&gt; removeFront();
        if ((curSpot-&gt;key[xCoor] == X) &amp;&amp; (curSpot-&gt;key[yCoor] == Y)) {
            result.insertFront(new spot(*curSpot));
        }
        temp -&gt; insertFront(curSpot);
    }
    delete queue[index];
    queue[index] = temp;
    return result;
}
</code></pre>

<p>I believe that the problem is in my queue.h file because it's where I get all of the errors like "spot has not been declared".  Every time spot appears in queue.h I have at least one error.  I searched around for anything like this but all I could find was people trying to share one instance of a struct across multiple source files, or the obvious question of putting a struct in a header and including that header across multiple source files(which is what I'm doing but my problem seems to be a rather unique one).</p>
