class Rational {
const Rational operator*(const Rational& rhs) const
...
};
Rational oneHalf(1,2);
Rational result = oneHalf * 2;
result = 2 * oneHalf;
This was mentioned by scott meyers in Effective C ++, as shown below.
Even when the Rationl constructor is not explicit, one compiles and one does not. The reason is listed below:
It turns out that the parameters have the right to implicit conversion "only if they are listed in the parameter list."
The implicit parameter corresponding to the object on which the member function is called - one "this" indicates - never have the right to implicit conversions. Thus, the first call compiles, and the second does not.
My question is what does the author in the above status mean "only if they are listed in the parameter list"? What is a parameter list?
source
share