In the first line:
comp = b*i;
Compiler call:
template<class T> complex<T> operator*(const T& val, const complex<T>& rhs);
What is defined as:
template<> complex<double> operator*(const double& val, const complex<double>& rhs);
In the second case, the corresponding int pattern does not exist, so the execution failed:
comp = 3.0 * i; // no operator*(int, complex<double>)
source share