Multidimensional array in class

Hello, I'm trying to write a chess game. I initialized the pieces as inegers, but now I have to create a board containing them. I don't know how to initialize the 8x8 array in other way than writing 64 elements in method. Please help the newbie. PS The names are in Polish.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
#include <iostream>
 
using namespace std;

class szachy
{
	int plansza[8][8]; //board

	static const int pionek=1; //chess pieces as integers
	static const int skoczek=2;
	static const int goniec=3;
	static const int wieza=4;
	static const int dama=5;
	static const int krol=6;


	void figury() //chess pieces to write on board
	{
	string figura;
	for (int a = 7; a > -1; a--)
	{
	cout << endl;
	 for (int b = 0; b < 8; b++)
	 {
	 switch (plansza[a][b])
	 {
	 case 0:
	 figura = "-";
	 break;
	 case pionek:
	 figura = "P";
	 break;
	 case skoczek:
	 figura = "S";
	 break;
	 case goniec:
	 figura = "G";
	 break;
	 case wieza:
	 figura = "W";
	 break;
	 case dama:
	 figura = "D";
	 break;
	 case krol:
	 figura = "K";
	 break;
	 case -pionek:
	 figura = "p";
	 break;
	 case -skoczek:
	 figura = "s";
	 break;
	 case -goniec:
	 figura = "g";
	 break;
	 case -wieza:
	 figura = "w";
	 break;
	 case -dama:
	 figura = "d";
	 break;
	 case -krol:
	 figura = "k";
	 break;
	 }
	  //cout << " " << figura << " ";
	 }
	}
	 cout<<endl<<endl;
	}
	
public:

	int nowa[8][8]; //startup board I want declare with integers and pieces
	void wpisz();

	void rysuj()//method that should transfer elements from startup to board
	{
	    for (int i = 0; i < 8; i++)
		{
	          for (int j = 0; j < 8; j++)
			  {
	            plansza[i][j] = 1;//nowa[i][j];
				cout<<plansza[i][j];
			  }
	     }
	 
	}

	 
	
	};
	 

int szachy::wpisz()
{
/*	nowa[8][8]=
	{
		{wieza,skoczek,goniec,dama,krol,goniec,skoczek,wieza},
		{pionek,pionek,pionek,pionek,pionek,pionek,pionek,pionek},
		{0,0,0,0,0,0,0,0},
		{0,0,0,0,0,0,0,0},
		{0,0,0,0,0,0,0,0},
		{0,0,0,0,0,0,0,0},
		{-pionek,-pionek,-pionek,-pionek,-pionek,-pionek,-pionek,-pionek},
		{-wieza,-skoczek,-goniec,-dama,-krol,-goniec,-skoczek,-wieza}
	}; 
I can't declare variables in class so that won't work/*
} */
Topic archived. No new replies allowed.