C ++错误:可能无法初始化可变大小的对象?

时间:2018-03-24 21:53:41

标签: c++ graphics

我一直想弄清楚为什么我会收到初始化错误:

int size = polygons[polyID].n;
    Clipper clipper = Clipper();
    Vertex tmp[50];
    size = clipper.clipPolygon(polygons[polyID].n, polygons[polyID].p, tmp, CWll, CWur);
    int x[size] = {};
    int y[size] = {}; 

我得到的错误是:

Pipeline.cpp:89:8: error: variable-sized object may not be initialized
        int x[size] = {};
              ^~~~
Pipeline.cpp:90:8: error: variable-sized object may not be initialized
        int y[size] = {}; 

有没有人知道可能导致此问题的原因?

0 个答案:

没有答案