0
反正在C++ 11要做到這一點:轉換複雜<int16_t>複雜<double>
std::complex<int16_t> integer(42,42);
std::complex<double> doub(25.5,25.5);
std::complex<double> answer = integer*doub;
的錯誤是
error: no match for ‘operator*’ (operand types are
‘std::complex<short int>’ and ‘std::complex<double>’)
std::complex<double> answer = integer*doub;
我已經試過的static_cast喜歡;
std::complex<double> answer = static_cast<std::complex<double>>(integer)*doub;