5 years ago.

C++ multidimensional array in class

  1. include <iostream>

using namespace std;

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

static const int pionek=1; 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() { 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];

void wpisz();

void rysuj() { 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} }; }

  • /
Be the first to answer this question.