c++ - Chessboard Class give me error -


this class chessboard . how can resolve error compiler give ? thanks

the error " expected unqualified-id before '[' token|"

#ifndef scacchiera_h_included #define scacchiera_h_included  class chess { public:   private:     unsigned int rows = 0;     unsigned int columns = 0;     int[][]mat = new int[rows][columns]; };   #endif // scacchiera_h_included 

with of user changed code

class chess {  public:     chess(unsigned int a):mat(mat[a][a]){};  private:     int mat[0][0]; }; 

but compiler gives me error incompatible types in assignment of 'int' 'int [0][0]'|

int[][]mat = new int[rows][columns]; 

should

int mat[rows][columns]; 

if rows , columns constants. or

class chess { public:     chess(int r, int c) {         rows = r;         columns = c;         mat = new int*[rows];         for(int = 0; < rows; ++i)             mat[i] = new int[columns];     }  private:     unsigned int rows = 0;     unsigned int columns = 0;     int** mat = nullptr; }; 

Comments

Popular posts from this blog

c++ - No viable overloaded operator for references a map -

java - Custom OutputStreamAppender not run: LOGBACK: No context given for <MYAPPENDER> -

java - Cannot secure connection using TLS -