0
我试图设置默认值为布尔二维数组称为“显示[宽度] [高度]”为false。我收到错误“智能感知:对于此子对象初始值设定项不能省略花括号”。问题是我之前使用过这个代码,它的工作,但不再。我有这两种实现和头文件:我似乎无法为多维数组设置默认值在c + +
Matrix.cpp(我已经表明我在那里得到的错误)
#include "Matrix.h"
Matrix::Matrix():
display{ false } // error is in this line
{
}
Matrix.h
#pragma once
#include "SDL.h"
#include "SDL_image.h"
#include "SDL_ttf.h"
#include <iostream>
class Matrix{
public:
Matrix();
enum { Width = 10, Height = 20 };
private:
bool display[Width][Height];
};
它工作正常与gcc和铛。 –
你尝试过空括号吗?即显示{}? –
我试过显示{},它工作正常!非常感谢你 :) – soso