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.
如果您想要我们STL队列容器,只需将其声明如下。
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*>
就是这样
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.