Dans un de mes cours, mon professeur nous a demandé de crée une liste de Client. Donc j'ai une class Client et Liste ( la liste est faite par moi et non par la library "liste.h" )

Je vous montre ma class Client elle ne fait pas grande chose à part stocker des information.

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#include <iostream>
#include <string>
using namespace std;
 
class Clients
{
	string nom_;
	string prenom_;
	string adresse_;
	int idClient_;
	unsigned int nbAchat_;
	double totalAchat_;
 
public:
 
	void SetNom(string nom)
	{ nom_ = nom; }
 
	void SetPrenom(string prenom)
	{ prenom_ = prenom; }
 
	void SetAdresse(string adr)
	{ adresse_ = adr; }
 
	void SetId(int id)
	{ idClient_ = id; }
 
	void SetNbAchat(int nb)
	{ nbAchat_ = nb; }
 
	void SetTotal(double total)
	{ totalAchat_ = total; }
 
	void SetAll(string nom,string prenom,string adr,int id,int nb,double total)
	{
		SetNom(nom);
		SetPrenom(prenom);
		SetAdresse(adr);
		SetId(id);
		SetNbAchat(nb);
		SetTotal(total);
	}
 
	string GetNom() const
	{ return nom_; }
 
	string GetPrenom() const
	{ return prenom_; }
 
	string GetAdresse() const
	{ return adresse_; }
 
	int GetIdClient() const
	{ return idClient_; }
 
	int GetNbAchat() const
	{ return nbAchat_; }
 
	double GetTotal() const
	{ return totalAchat_; }
 
	friend ostream& operator<<(ostream& os, Clients& client)
	{
		cout << client.GetNom() << " " << client.GetPrenom() << " " << client.GetAdresse() << " " << client.GetNbAchat() << " " << client.GetTotal() << endl;
		return os;
	}
};
Dans une des méthodes de ma class liste je dois faire une comparaison d'objet ,dout le fait que j'ai besoin de surcharger l'opérateur ==

voici la méthode :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
	void RechercherCourant(Objet objet)
	{
		NoeudPtr courant = _tete;
		if (_tete)
		{
			do 
			{
				if (*courant->objetPtr == objet)
					break;
				courant = courant->suivant;
				if (courant == _tete)
					courant = null;
			}while (courant);
		}
		_courant = courant;
	}
dans mon main j'ai la variable
Clients client;
Liste<Clients> ListeClient;

EDIT : je crois que j'ai trouvé comment overload l'opérateur == pour ma class mais je ne suis pas sûr si c'est la bonne méthode
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
	friend bool operator==(Clients& client1,Clients& client2)
	{
		return ((client1.nom_ == client2.nom_
			&& client1.prenom_ == client2.prenom_
			&& client1.adresse_ == client2.adresse_
			&& client1.idClient_ == client2.idClient_
			&& client1.nbAchat_ == client2.nbAchat_
			&& client1.totalAchat_ == client2.totalAchat_));
	}