I have the following class declaration:
Class A { A &operator =(const ACHAR *s); // (1) A &operator =(A &a); // (2) A operator +(const ACHAR *s); // (3) operator ACHAR*(); // (4) }; Now, when I run this code:
A x,y; ACHAR *p; x=y; // (2) x=y+p; (3)(4)(1) The first assignment x=y invoke the (2) operator=, as expected.
But the second assignment provoke the cast operator, and the (1) operator=.
Now, since the (3) operator+ returns class A, I would expect (2) operator= to be called.
Why is this happen, and how to resolve *this?
Thanks in advance!