Hi,
This is a simple question. In the following example,
.. class Vector
.. {
.. private:
.. int *Numbers;
.. int vLength;
..
.. public:
.. Vector()
.. Vector(int vLengthP, int *NumbersP = NULL);
..
.. // ...
..
.. Vector& operator=(int scalarTerm);
.. Vector& operator=(const Vector& another);
..
.. // ...
..
.. };
If I have statements such as:
Vector b(4);
b = 10;
Can I be 100% sure that the compiler will always call the
operator=(scalar) for this statement instead of calling the constructor
Vector(int) (interpreted as an implicit type conversion constructor)
and then calling operator=(Vector &) ? I tried a simple example with
g++ and it worked as expected. But I am confused because the type
conversion operator has precedence over the assignment operator. Or am
I looking at this in a completely wrong way ? Please explain.
Thanks in Advance,
Vijay.
--
P.S: My id "Master of C++" has more to do with my favorite album
"Master of Puppets" than with my proficiency in C++.