Les erreurs suivantes pointent toujours vers ma liste.Liste C++ Unique() Fonction
Dans mon fichier de classe
Point3D operator==(const Point3D &p1) const;
Dans mon fichier .cpp
bool operator==(Point3D &p1, Point3D &p2)
{
if (p1.getX() == p2.getX() && p1.getY() == p2.getY() && p1.getZ() == p2.getZ())
return true;
else
return false;
}
Dans mon fichier principal
//declaration
list<Point3D> l_3D;
l_3D.unique(); <-- the error point to this
Message d'erreur
..... In member function 'void std::list<_Tp,_Alloc>::unique() [with_Tp = Point3D,_Alloc = std:: allocator<Point3D>]:
Instantiated from here
error: could not convert 'Point3D::operator==(const Point3D&) const (((const Point3D&)((const Point3D*)__next. std::_List_iterator<_Tp>::operator*[with_Tp = Point3D]())))' to 'bool'
Pour les âmes aimables là-bas, je vous remercie d'avance.
Aussi, au lieu de 'if (some_bool_expression) renvoie true; else return false, ', il est plus idiomatique d'avoir' return some_bool_expression; ' –
Cela me fait toujours frissonner quand les gens écrivent 'if (a) return true; sinon retournez faux; au lieu de simplement «retourner un». : -} –