25/11/18 13:12
Thejuster
Salve ragazzi, Mi sto ancora dilettando con il mio progetto Mappy
( pierotofy.it/pages/sorgenti/dettagli/19563-Mappy/ )
Ho un problema quando devo eseguire un confronto tra due strutture.
E credo che anche stavolta, mi confondo tra C# e Cpp.
dunque il codice è il seguente
error: no match for 'operator==' (operand types are 'MappySaver::Tile' and 'MappySaver::Tile')
if(m.Tiles[i] == m.Tiles[j])
^
Non è che forse devo fare un override dell'operatore per verificare l'integrità?
In C# bastava fare un semplice == per verificare una struttura se combacia con l'altra.
Dovrei procedere in questo modo?
( pierotofy.it/pages/sorgenti/dettagli/19563-Mappy/ )
Ho un problema quando devo eseguire un confronto tra due strutture.
E credo che anche stavolta, mi confondo tra C# e Cpp.
dunque il codice è il seguente
qDebug() << m.Tiles.count(); for(int i = 0; i <m.Tiles.count(); i++) { MappySaver::Tile t = static_cast<MappySaver::Tile>(m.Tiles[i]); int duplicates = 0; for(int j = 0; j < m.Tiles.count(); j++) { if(m.Tiles[i] == m.Tiles[j]) //Errore qui duplicates++; } if(duplicates > 1) m.Tiles.removeAt(i); }
error: no match for 'operator==' (operand types are 'MappySaver::Tile' and 'MappySaver::Tile')
if(m.Tiles[i] == m.Tiles[j])
^
Non è che forse devo fare un override dell'operatore per verificare l'integrità?
In C# bastava fare un semplice == per verificare una struttura se combacia con l'altra.
Dovrei procedere in questo modo?
bool operator == (const MappySaver::Tile &tile, MappySaver::Tile &match) { if(tile.ID == match.ID && tile.X == match.X ecc. ecc. ecc. return true; }
mire.forumfree.it/ - Mire Engine
C# UI Designer
C# UI Designer