c++ 编译器没报错但是poj编译错误


#include <iostream>
#include <queue>
using namespace std;
char a[22][22];
int turn[4][2] = {{1, 0}, {0, -1}, {-1, 0}, {0, 1}};
typedef struct m
{
    int x, y;
} ob;
int main()
{
    int w, h;
    while (cin >> w >> h)
    {
        ob st;
        for (int i = 1; i <= h; i++)
        {
            getchar();
            for (int j = 1; j <= w; j++)
            {
                cin >> a[i][j];
                if (a[i][j] == '@')
                {
                    st.x = j, st.y = i;
                }
            }
        }
        int sum = 1;
        queue<ob> line;
        line.push(st);
        a[line.front().y][line.front().x] = 0;
        do 
        {
           

            for (int i = 0; i < 4; i++)
            {
                if (a[line.front().y + turn[i][1]][line.front().x + turn[i][0]] == '.') 
                {                                                                       
                    line.push({line.front().x + turn[i][0], line.front().y + turn[i][1]});
                    a[line.front().y + turn[i][1]][line.front().x + turn[i][0]] = 0;
                    sum++;
                }
            }
            line.pop();
        } while (line.size());
        cout << sum<<endl;
    }
    return 0;
}

附上oj信息:
Compile Error

Main.cpp
F:\temp\23176735.14851\Main.cpp(40) : error C2143: syntax error : missing ')' before '{'
F:\temp\23176735.14851\Main.cpp(40) : error C2660: 'std::queue<_Ty>::push' : function does not take 0 arguments
with
[
_Ty=ob
]
F:\temp\23176735.14851\Main.cpp(40) : error C2143: syntax error : missing ';' before '{'
F:\temp\23176735.14851\Main.cpp(40) : error C2143: syntax error : missing ';' before '}'
F:\temp\23176735.14851\Main.cpp(40) : error C2059: syntax error : ')'

因为在第40行你用C++11语法line.push({ ... })使用初始化列表创建结构体,目前主流C++编译默认支持C++11。似乎你们POJ系统仍然默认C++03,而不是C++11。
你可以把那行修改为

ob s = {line.front().x + turn[i][0], line.front().y + turn[i][1]};
line.push(s);