1
Having the struct
struct bloco {
bloco () : real(), marcado('.'){}
char real;
char marcado;
};
When I try
void tabuleiro (int lado, int mina){
...
bloco tab[lado][lado];
...
for (i=0, j=0; lado>i; i++){
for (j=0; lado>j; j++){
tab[i][j].real = '.';
}
}
...
jogar(tab[lado][lado]);
return;
}
And in the role play I have
void jogar(bloco tab){
tab[x][y].marcado = 'M';
}
I get the message
no match for 'Operator[]' (operand types are 'block' and 'int') tab[x][y]. marked = ’M';
As far as I understand it, it means that I did not pass "tab" as being an array, so I tried to solve with:
void jogar(int lado, bloco tab[lado][lado]){
tab[x][y].marcado = 'M';
}
Who gave me the following message
error: use of Parameter 'side' Outside Function body void play(int side, block tab[side][side]){
I just wanted to pass the struct matrix created in one function to change it in the other, but I don’t know how :(
Thank you very much! I used
vector <vector<bloco> > tab(lado, vector<bloco>(lado));
and solved my compilation problems. Now there are other logic, but these I can solve with a little study!– Davi Grimaldi