在构造函数-C+中的类头/赋值中声明字符串数组+; 我在C++中创建了一个小游戏。我想在类中声明我的映射,并在类的构造函数中赋值

在构造函数-C+中的类头/赋值中声明字符串数组+; 我在C++中创建了一个小游戏。我想在类中声明我的映射,并在类的构造函数中赋值,c++,arrays,string,C++,Arrays,String,我从2天就开始写了,这让我大吃一惊(我把它放在了“全球”中,以便暂时继续) 这是我的档案: map.cpp Map::Map() : width(21), height(21) { this->array[] = {"011111111111111111110", "012222222212222222210", // Some strings // "0111111111

我从2天就开始写了,这让我大吃一惊(我把它放在了“全球”中,以便暂时继续)

这是我的档案:

map.cpp

Map::Map() : width(21), height(21)
{
  this->array[] = {"011111111111111111110",
                   "012222222212222222210",
                   // Some strings //
                   "011111111111111111110"};
}
class                   Map
{
  const unsigned short  width;
  const unsigned short  height;
 public:
  extern std::string array[21];
  Map();
  ~Map();
};
map.hpp

Map::Map() : width(21), height(21)
{
  this->array[] = {"011111111111111111110",
                   "012222222212222222210",
                   // Some strings //
                   "011111111111111111110"};
}
class                   Map
{
  const unsigned short  width;
  const unsigned short  height;
 public:
  extern std::string array[21];
  Map();
  ~Map();
};
有人能帮我做这个/解释一下怎么做吗?我在这个论坛上尝试了许多解决方案,但没有成功:/

谢谢

我建议您使用数组而不是数组:使用它会更容易