M
mathieu
Hi there,
I'd like to know what is the defined behavior for the following (*).
Basically when there is more than one suitable operator, what does the
compiler choose ?
Thanks
-Mathieu
(*)
struct A
{
friend bool operator == (const A & a, const A & b);
A():a(0) {}
private:
bool operator == (const A & aa)
{
return aa.a == a;
}
int a;
};
bool operator == (const A & a, const A & b)
{
return a.a == b.a;
}
int main()
{
A a1;
A a2;
bool b = a1 == a2;
return 0;
}
I'd like to know what is the defined behavior for the following (*).
Basically when there is more than one suitable operator, what does the
compiler choose ?
Thanks
-Mathieu
(*)
struct A
{
friend bool operator == (const A & a, const A & b);
A():a(0) {}
private:
bool operator == (const A & aa)
{
return aa.a == a;
}
int a;
};
bool operator == (const A & a, const A & b)
{
return a.a == b.a;
}
int main()
{
A a1;
A a2;
bool b = a1 == a2;
return 0;
}