相关疑难解决方法(0)

无法为数组指定显式初始值设定项

我收到以下编译错误...

error C2536: 'Player::Player::indices' : cannot specify explicit initializer for arrays 
Run Code Online (Sandbox Code Playgroud)

为什么是这样?

class Player
{
public:
    Player();
    ~Player();

    float x;
    float y;
    float z;
    float velocity;

    const unsigned short indices[ 6 ];
    const VertexPositionColor vertices[];
};
Run Code Online (Sandbox Code Playgroud)

CPP

Player::Player()
:
    indices
    { 
        3, 1, 0,
        4, 2, 1 
    },
    vertices{
        { XMFLOAT3( -0.5f, -0.5f, -0.5f ), XMFLOAT3( 0.0f, 0.0f, 0.0f ) },
        { XMFLOAT3( -0.5f, 0.5f, -0.5f ), XMFLOAT3( 0.0f, 0.0f, 1.0f ) },
        { XMFLOAT3( 0.5f, -0.5f, -0.5f ), …
Run Code Online (Sandbox Code Playgroud)

c++ visual-studio-2013

8
推荐指数
1
解决办法
2万
查看次数

标签 统计

c++ ×1

visual-studio-2013 ×1