Bonjour,

j'aimerai savoir comment on teste l'égalité entre deux maps.

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
 
 
class A
{
...
}
 
class B
{
...
 bool operator==(const B& b){...}
}
 
 
typedef map<const A,B> mAB;
 
mAB a, b, c;
 
a[A(1)]=B(1);
a[A(2)]=B(2);
a[A(3)]=B(3);
 
b[A(1)]=B(1);
b[A(2)]=B(2);
b[A(3)]=B(3);
 
a==b // doit retourner vrai
 
c[A(1)]=B(1);
c[A(2)]=B(2);
c[A(3)]=B(4);
 
a==c // doit retourner false
g++ me dit à la compilation

/usr/include/c++/4.1.3/bits/stl_pair.h:97: error: no match for ‘operator==’ in ‘__x->std::pair<const A, B>::second == __y->std::pair<const A, B>::second’

...

candidates are: bool parser_set::operator==(const B&) <near match>

merci d'avance de votre aide