• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1261
  • 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
Cloud Class® Course: SQL Server Core 2016

This course will introduce you to SQL Server Core 2016, as well as teach you about SSMS, data tools, installation, server configuration, using Management Studio, and writing and executing queries.

 
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
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: CompTIA Healthcare IT Tech

This course will help prep you to earn the CompTIA Healthcare IT Technician certification showing that you have the knowledge and skills needed to succeed in installing, managing, and troubleshooting IT systems in medical and clinical settings.

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