Miguelowski Posted January 26, 2016 at 03:46 PM Report Share #592566 Posted January 26, 2016 at 03:46 PM Tenho uma classe Tabuleiro Tabuleiro::Tabuleiro() { int i; Nc = 3; Nl = 3; Matriz = new char*[Nl]; for (i = 0; i < Nl; i++){ Matriz[i] = new char[Nc]; } Inicia(); } Tabuleiro::Tabuleiro(int mnc, int mnl) { int i; Nc = mnc; Nl = mnl; Matriz = new char*[Nl]; for (i = 0; i < Nl; i++){ Matriz[i] = new char[Nc]; } Inicia(); } Tabuleiro::~Tabuleiro() { for (int i = 0; i < Nl; i++){ delete Matriz[i]; } delete Matriz; } void Tabuleiro::Inicia(){ cout << "\n"; int i, j; for (i = 0; i < Nl; i++){ for (j = 0; j < Nc; j++){ Matriz[i][j] = '.'; } } } Como faço a sobrecarga do operador == para verificar se o tabuleiro inicial e igual ao tabuleiro depois de preenchido? alguem me sabe dizer se ficaria assim? bool tabuleiro::operator == (const Tabuleiro T) const { bool igual= true; . if(tabuleiro !=T) igual=false; return igual; } Link to comment Share on other sites More sharing options...
HappyHippyHippo Posted January 26, 2016 at 04:29 PM Report Share #592569 Posted January 26, 2016 at 04:29 PM bool tabuleiro::operator == (const Tabuleiro T) const // <-- isto está bem { bool igual= true; // \ . // | if(tabuleiro !=T) // | isto não faz sentido nenhum igual=false; // | sabes o que é uma pescadinha de rabo na boca ? // | return igual; // / } IRC : sim, é algo que ainda existe >> #p@p Portugol Plus Link to comment Share on other sites More sharing options...
Miguelowski Posted January 26, 2016 at 04:32 PM Author Report Share #592571 Posted January 26, 2016 at 04:32 PM pois, eu imaginava que nao, mas nao consegui perceber como fazer dentro do operador... o que tenho de fazer? Link to comment Share on other sites More sharing options...
HappyHippyHippo Posted January 26, 2016 at 04:35 PM Report Share #592572 Posted January 26, 2016 at 04:35 PM diz tu : o que tens de ser igual nas duas classes para que possam ser consideradas como iguais ? IRC : sim, é algo que ainda existe >> #p@p Portugol Plus Link to comment Share on other sites More sharing options...
Miguelowski Posted January 26, 2016 at 04:40 PM Author Report Share #592574 Posted January 26, 2016 at 04:40 PM o tabuleiro vai ser preenchido pelos jogadores e depois tenho de fazer essa sobrecarga para ver se o tabuleiro inicial e igual ao preenchido quando a primeira jogada for feita o tabuleiro sera logo diferente _|_|_ inicial preenchido x|o|x _|_|_ o|o|x | | x|o|x Link to comment Share on other sites More sharing options...
HappyHippyHippo Posted January 26, 2016 at 04:40 PM Report Share #592575 Posted January 26, 2016 at 04:40 PM responde somente à pergunta, tudo o resto é me irrelevante IRC : sim, é algo que ainda existe >> #p@p Portugol Plus Link to comment Share on other sites More sharing options...
Miguelowski Posted January 26, 2016 at 04:42 PM Author Report Share #592577 Posted January 26, 2016 at 04:42 PM os tabuleiros isto e as matrizes Link to comment Share on other sites More sharing options...
HappyHippyHippo Posted January 26, 2016 at 04:51 PM Report Share #592580 Posted January 26, 2016 at 04:51 PM isto e as matrizes e o que são os "tabuleiros" e as "matrizes" ? IRC : sim, é algo que ainda existe >> #p@p Portugol Plus Link to comment Share on other sites More sharing options...
Miguelowski Posted January 26, 2016 at 04:52 PM Author Report Share #592581 Posted January 26, 2016 at 04:52 PM (edited) arrays e os pontos Edited January 26, 2016 at 04:53 PM by Miguelowski Link to comment Share on other sites More sharing options...
HappyHippyHippo Posted January 26, 2016 at 05:15 PM Report Share #592582 Posted January 26, 2016 at 05:15 PM então tens de comparar os arrays e os "pontos" IRC : sim, é algo que ainda existe >> #p@p Portugol Plus Link to comment Share on other sites More sharing options...
Miguelowski Posted January 26, 2016 at 05:24 PM Author Report Share #592583 Posted January 26, 2016 at 05:24 PM If(nc!=t.nc) If (nc!=t.nl) False Retorno True Fazer estas comparações? Link to comment Share on other sites More sharing options...
HappyHippyHippo Posted January 26, 2016 at 05:58 PM Report Share #592587 Posted January 26, 2016 at 05:58 PM é assim que se compara arrays ? IRC : sim, é algo que ainda existe >> #p@p Portugol Plus Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now