4
I have two classes:
class CAlbum
{
private:
    QString Nome; /**< Nome do Álbum */
    QString Descricao; /**< Descrição do Álbum */
    QString Diretoria; /**< Diretoria onde se encontra o Álbum */
    //QPixmap Imagem;
    std::vector <CInterprete> Interpretes; /**< Informação relativa aos Intérpretes associados ao Álbum */
    std::vector <CMusica> Musicas; /**< Músicas presentes no Álbum */
public: ...
}
class CInterprete
{
    QString Nome; /**< Nome do Intérprete */
    QString Nacionalidade; /**< Nacionalidade do Intérprete */
    QDate Nascimento; /**< Data de Nascimento do Intérprete */
public: ...
}
And one of the operators I have in class CAlbum is as follows:
bool CAlbum::elimina_Interprete(const QString nome_Interprete){
    int i;
    for ( i = 0 ; i < (int) Interpretes.size() ; i++){
        if (Interpretes[i].retorna_Nome() == nome_Interprete){
            Interpretes.erase(Interpretes.begin()+i);
            return true;
        }
    }
    return false;
}
I’ve tried applying the same idea but with Iterators and it didn’t work, always giving me a mistake
Debug Assertion Failed! Expression: vector Erase iterator Outside range"
How is it that with this function I find myself eliminating outside the crease?
Thank you for your time. The problem is right on this piece of code. I had checked earlier through qDebug(). Regarding Qvector I didn’t even know it :) It’s the first time I’m working with vectors. I’ll make that change ;) Thank you.
– Dylan Bicho
Qvector solved the problem!! Thanks for the help ;)
– Dylan Bicho