Unable to convert closed loop initializer list

I declare a table with boolers and initialize it to main()

const int dim = 2;
bool Table[dim][dim];

int main(){

     Table[dim][dim] = {{false,false},{true,false}};
     // code    
     return 0;
}

I use the mingwcompiler, and the linker options g++ -std=c++11. Error

cannot convert the list of initializers enclosed in curly braces to 'bool' in assignment`

+4
source share
3 answers

Arrays can be initialized in the same way as in the definition, after that you will not be able to execute them.

Move initialization to the definition or initialize each entry manually.

+5
source

. -, , .

:

bool Table = {{false,false},{true,false}};
0

You can use memset(Table,false,sizeof(Table))for this.it will work fine.

Here is your complete code

#include <iostream>
#include<cstring>
using namespace std;

   const int dim = 2;
    bool Table[dim][dim];

    int main(){

         memset(Table,true,sizeof(Table));
         cout<<Table[1][0];
// code    
return 0;
    }
0
source

Source: https://habr.com/ru/post/1534623/