c++ map 嵌套队列指针,队列嵌套结构体指针
#include <iostream>
#include <queue>
#include<map>
#include <string>
#include <mutex>
//#include <Windows.h>
using namespace std;
queue<RevData*> queue1;
/*queue<RevData*>* queue2;*/
//queue2 = (queue<RevData*>*)malloc(sizeof(queue<RevData*>));
for (int i = 0; i < 10; i++) {
RevData recvD;
recvD.size = i;
strcpy(recvD.data, "hello");
RevData* recvp = (RevData*)malloc(sizeof(RevData));
memcpy(recvp, &recvD, sizeof(RevData));
queue1.push(recvp);// recvp);
//queue1.push(&recvD);
}
map<int, queue<RevData*>*> imap;
map<int, queue<RevData*>*>* queue2;
//queue2 = (queue<RevData*>*)malloc(sizeof(queue<RevData*>));
for (int i = 0; i < 1; i++) {
imap[i]= &queue1;// recvp);
//imap[i]=&recvD;
}
queue2 = &imap;
for (int i = 0; i < 1; i++) {
queue<RevData*>* recv = (*queue2)[i];
for (int j = 0; j < 10; j++) {
RevData* recvd = recv->front();
cout << (*recvd).data << endl;
cout << (*recvd).size << endl;
int lenga = recv->size();
recv->pop();
}
}
文章来源: blog.csdn.net,作者:网奇,版权归原作者所有,如需转载,请联系作者。
原文链接:blog.csdn.net/jacke121/article/details/79371894
- 点赞
- 收藏
- 关注作者
评论(0)