problème avec sort() et operator<
Bonjour,
Je ne sais pas si je n'aurais pas dû poster dans la section STL ? Mais je ne crois pas que ce soit un pb STL à proprement parler...bref, voici :
J'ai une classe point :
Code:
1 2 3 4 5 6 7 8 9 10 11
| class point{
public :
double x, y, angle;
bool operator< (const point& p1);
};
bool point::operator< (const point &p1)
{
if (angle < p1.angle) return true;
return false;
} |
et dans une autre classe, j'ai un vector de point, auquel je fais subir ce traitement :
Code:
1 2 3 4 5 6
|
vector<point> liste;
/*initialisations, machin patin, couffin */
sort(liste.begin(),liste.end()); |
moyennant quoi, je me retrouve avec :
no match for 'operator<' in '__a < __b'
candidats sont:bool point::operator<(const point&) <near match>
Ce near match me tue...qqn aurait une suggestion ? Apparemment sort est malheureux avec ma définition de operator<...
Merci :)
Hugo