Hi, all. I have a question about the conversion of double to complex<double>.
I defined operator+ between MyClass and complex<double>: const MyClass operator+(const MyClass& lhs,const complex<double>& rhs);
Hence, I can think of the expression such as x+a for MyClass x; and complex<double> a;
I like to know whether I can calculate x+b for double b; using implicit conversion of double to complex<double>.
(the implicit conversion rule I would like to define is from double x to complex<double>(x,0.). )
Of course, I know that x+complex<double>(b,0); gives me the same result. Or I could deinfe operator+ between MyClass and double.
But, I guest there is a natural(?) way to do that.
In other words, for the function double f(double x);
we can think of f(i) for int i; due to the implicit conversion from int to double.
I would like to do the same similar thing for the operation +.
Is there a way to do that??