C++中queue能存数组吗?

如题
queue searchlist;
queue中存数组,每一个元素是一个二维坐标。这样行吗?
声明okay,但是searchlist.push()就不行了

你需要声明一个结构体或者类,把他作为queue的元素

 #include<iostream>
#include<queue>
using namespace std;

struct Point
{
    int x;
    int y;
};

int main()
{
    queue<Point> searchlist;
    Point a = {5, 19};
    Point b = {3, 10};
    Point c = {4, 12};
    searchlist.push(a);
    searchlist.push(b);
    searchlist.push(c);
    while(!searchlist.empty())
    {
        Point temp = searchlist.front();
        cout << "[" << temp.x << "," << temp.y << "]" << endl;
        searchlist.pop();
    }
    system("pause");
    return 0;
}

放指针的指针不就行了?

queue<数据类型>

可以的,其实Queue就类似一个数组,一个装东西的容器,就像你可以在数组里放数组一样

不仅仅是数组,只要能称之为对象的东西 ,都是可以的

我也遇到了,发现不能存数组,报错:a.cpp:10:8: error: no matching member function for call to 'push'