Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1162
  • Last Modified:

Can I have a static std::queue ?

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?
0
oxygen_728
Asked:
oxygen_728
  • 3
  • 3
2 Solutions
 
jkrCommented:
Please post more of your code, this is probably just a simple syntax problem.
0
 
oxygen_728Author Commented:
Code:


struct Buffer{
      int Length;
      char* TheBuffer;
};

class RString
{
private:

      //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 ';'
0
 
jkrCommented:
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;

0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
oxygen_728Author Commented:

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'
0
 
jkrCommented:
Do you also

#include <queue>

?
0
 
oxygen_728Author Commented:
#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
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

  • 3
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now