Problem: Accessing Vector Inside a Thread
<p>I got a link error when I tried to access vector outside my thread. My design is, when I get a message from a client, I want the massage or data to be in my data queue for further operation. But I can't get them work. Here is my codes:</p>

<p>.cpp file:</p>

<pre><code>// Inside the recv thread
start:
    err = recvfrom(RecvSocket, lpData-&gt;RecvBuf, BufLen, 0, (SOCKADDR *)&amp;lpData-&gt;SenderAddr, &amp;SenderAddrSize);
    //lpData is used to access Recv Structure which stores the attributes of the server and client.

    switch(lpData-&gt;port)
    {
        case 6516:
        {
            BuffStack1.push_back(lpData-&gt;RecvBuf);
            break;
        }

        case 6517:
        {   
            break;
        }

        case 6518:
        {
            break;
        }
    }

goto start;
</code></pre>

<p>.h file:</p>

<pre><code>class CUdpSocket
{
public:
    CUdpSocket(void);
    ~CUdpSocket(void);
    void ServerRecv(int port);
    void ClientSend(const char *ip, int port, const char *buff);
    unsigned static __stdcall ServerRecvThread(void *arguments);
    unsigned static __stdcall ClientSendThread(void *arguments);
    CString static Itoa(int data);
    void Mix();

private:
    RecvStruct *pRecvData;
    SendStruct *pSendData;
    vector&lt;HANDLE&gt;threadStl;
    static vector&lt;char*&gt;BuffStack1;  // Here is my stack vector
    static vector&lt;char*&gt;BuffStack2;
    static vector&lt;char*&gt;BuffStack3;
    HANDLE hThread;
    unsigned threadID;
    static BufferData *ptrBufferData;
};
</code></pre>

<p>I am a bit confused whether I need to put static or not. And when I put static, the error will be:</p>

<pre><code>error LNK2001: unresolved external symbol "private: static class std::vector&lt;char *,class std::allocator&lt;char *&gt; &gt; CUdpSocket::BuffStack1" (?BuffStack1@CUdpSocket@@0V?$vector@PADV?$allocator@PAD@std@@@std@@A)
</code></pre>

<p>And if I didn't put static statement, the error says:</p>

<pre><code>error C2228: left of '.push_back' must have class/struct/union
</code></pre>

<p>Please help.</p>

<p>Thank you.</p>
