Can I have a static std::queue ?

Posted on 2006-05-29
Last Modified: 2013-12-14
I'm trying to declare a static std::queue

static queue<myObject*> TheQueue;

This gets a parsing error...

My ultimate goal: A static array of queues

static queue<myObject*> TheQueue[10];

but this gets the same paring error.

Any ideas?
Question by:oxygen_728
    LVL 86

    Expert Comment

    Please post more of your code, this is probably just a simple syntax problem.

    Author Comment


    struct Buffer{
          int Length;
          char* TheBuffer;

    class RString

          //Static Stuff
          static queue<Buffer*> DeadQueue;       // <--- Errors here  
          static Buffer* CurrentBuffer;

          //Instance Stuff
          char* buffer;
          unsigned int BufferLength;

      ... boring stuff... (functions)


    Compiler Errors:
     error C2143: syntax error : missing ';' before '<'
     error C2238: unexpected token(s) preceding ';'
    LVL 86

    Assisted Solution

    Does adding

    using namespace std;

    after the STL includes help? At least it looks like that. You could of ccourse also try

         static std::queue<Buffer*> DeadQueue;


    Author Comment


    I get this error when using  static std::queue<Buffer*> DeadQueue;
    error C2039: 'queue' : is not a member of 'std'

    I get the same errors as above when using namespace std; is inserted up top - I think it was already 'active' though, i had that in a different file in the project already.

    I think the compiler is getting goofed up with the 'static'
    LVL 86

    Accepted Solution

    Do you also

    #include <queue>


    Author Comment

    #include <queue>   was the trick.

    After solving some very painful linker issues (which involved shutting off pre-compiled headers), I got it working.

    Thanks for the help JKR

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    IT, Stop Being Called Into Every Meeting

    Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

    What is C++ STL?: STL stands for Standard Template Library and is a part of standard C++ libraries. It contains many useful data structures (containers) and algorithms, which can spare you a lot of the time. Today we will look at the STL Vector. …
    This article shows you how to optimize memory allocations in C++ using placement new. Applicable especially to usecases dealing with creation of large number of objects. A brief on problem: Lets take example problem for simplicity: - I have a G…
    The viewer will learn how to synchronize PHP projects with a remote server in NetBeans IDE 8.0 for Windows.
    The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.

    737 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    22 Experts available now in Live!

    Get 1:1 Help Now