C++ queue - simple example
106,729
Solution 1
Simply declare it as below if you want to us the STL queue container.
std::queue<myclass*> my_queue;
Solution 2
std::queue<myclass*> my_queue;
will do the job.
See here for more information on this container.
Solution 3
std::queue<myclass*>
that's it
Related videos on Youtube
Author by
Ondra
Updated on July 09, 2022Comments
-
Ondra almost 2 years
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.
-
Tim Barrass over 13 yearsis this using your own queue implementation, or something else?
-
Ondra over 13 yearsi am using std::queue on linux, but i am lookig for any possible solution...
-
-
Flexo over 13 years@RedX: This one got my vote because it's more complete and mentioned STL.