cannot specify explicit initializer for arrays

前端 未结 2 863
误落风尘
误落风尘 2020-12-11 03:49

I\'m getting the following compile error...

error C2536: \'Player::Player::indices\' : cannot specify explicit initializer for arrays 

why

2条回答
  •  星月不相逢
    2020-12-11 04:37

    The size of the array needs to be defined in the class definition. C++ doesn't support variable sized arrays, at least, not yet:

    class Player
    {  
    public:
        // ...
        const unsigned short indices[ 6 ];
        const VertexPositionColor vertices[4];
    };
    

    Assuming a suitable definition of VertexPositionColor this should be OK (it compiles with gcc and clang using -std=c++11).

提交回复
热议问题