> 1) If you do not define an assignment operator in your class
> the compiler will create a default one for you.
Sorry I did not finish that one:
The created default operator definition
will result in an ambigous call whenever
you'll use the assignment
ex:
class A {
public:
A(int i) : _i(i) {}
friend A& operator=(A& lhs, const A& rhs);
private:
int i;
};
A& operator=(A& lhs, const A& rhs) {
lhs._i = rhs._i;
}
int main() {
A a(0), b(10);
a = b;
}
leads to the following error msg: (GCC 3.2, Linux Mandrake 9.0, Intel
Pentium):
See the *** line
launcher.C:11: `A& operator=(A&, const A&)' must be a nonstatic member
function
launcher.C:18: `A& operator=(A&, const A&)' must be a nonstatic member
function
launcher.C: In function `int main()':
launcher.C:25: ambiguous overload for `A& = A&' operator ***
launcher.C:6: candidates are: A& A:

perator=(const A&)
launcher.C:18: A& operator=(A&, const A&)
launcher.C:18: A& operator=(A&, const A&)
--
Jan Rendek
INRIA, Lorraine
r e n d e k @ l o r i a . f r