[c++] C++ queue - simple example

I can't find simple example how to use queues in C++ for pointers to some myclass objects. I have code like this:

class myclass{
  string s;
};

myclass *p = new myclass();

my_queue.push(p);

//something....

p = my_queue.front();
my_queue.pop();

std::cout << p->s;

What should be declaration of my_queue? Should I use queue or another data structure?

I need c++ just for small program, thanks for answers.

This question is related to c++ queue

The answer is


Simply declare it as below if you want to us the STL queue container.

std::queue<myclass*> my_queue;

std::queue<myclass*> my_queue; will do the job.

See here for more information on this container.


std::queue<myclass*> that's it