complex numbers error
-
Hi, may u plz look at this error: #include using namespace std; complex i(0,1); // to get i=sqrt(-1) !! complex c3 = 1/i ; The last line gives the following error: error C2782: 'class std::complex<_Ty> __cdecl std::operator /(const _Ty &,const class std::complex<_Ty> &)' : template parameter '_Ty' is ambiguous could be 'double' or 'int' error C2784: 'class std::complex<_Ty> __cdecl std::operator /(const class std::complex<_Ty> &,const _Ty &)' : could not deduce template argument for 'const class std::complex<_Ty> &' f rom 'const int' error C2784: 'class std::complex<_Ty> __cdecl std::operator /(const class std::complex<_Ty> &,const class std::complex<_Ty> &)' : could not deduce template argument for 'const class st d::complex<_Ty> &' from 'const int' error C2677: binary '/' : no global operator defined which takes type 'class std::complex' (or there is no acceptable conversion) Error executing cl.exe. It also doesn't accept: complex c3 = 1 + i ; Any help is highly appreciated! Regards, Eliyah
-
Hi, may u plz look at this error: #include using namespace std; complex i(0,1); // to get i=sqrt(-1) !! complex c3 = 1/i ; The last line gives the following error: error C2782: 'class std::complex<_Ty> __cdecl std::operator /(const _Ty &,const class std::complex<_Ty> &)' : template parameter '_Ty' is ambiguous could be 'double' or 'int' error C2784: 'class std::complex<_Ty> __cdecl std::operator /(const class std::complex<_Ty> &,const _Ty &)' : could not deduce template argument for 'const class std::complex<_Ty> &' f rom 'const int' error C2784: 'class std::complex<_Ty> __cdecl std::operator /(const class std::complex<_Ty> &,const class std::complex<_Ty> &)' : could not deduce template argument for 'const class st d::complex<_Ty> &' from 'const int' error C2677: binary '/' : no global operator defined which takes type 'class std::complex' (or there is no acceptable conversion) Error executing cl.exe. It also doesn't accept: complex c3 = 1 + i ; Any help is highly appreciated! Regards, Eliyah
I'm not really understanding what you're doing, but will something like this work?
complex c3 = 1/(int)i ;
My articles www.stillwaterexpress.com BlackDice
-
I'm not really understanding what you're doing, but will something like this work?
complex c3 = 1/(int)i ;
My articles www.stillwaterexpress.com BlackDice
-
Hi, may u plz look at this error: #include using namespace std; complex i(0,1); // to get i=sqrt(-1) !! complex c3 = 1/i ; The last line gives the following error: error C2782: 'class std::complex<_Ty> __cdecl std::operator /(const _Ty &,const class std::complex<_Ty> &)' : template parameter '_Ty' is ambiguous could be 'double' or 'int' error C2784: 'class std::complex<_Ty> __cdecl std::operator /(const class std::complex<_Ty> &,const _Ty &)' : could not deduce template argument for 'const class std::complex<_Ty> &' f rom 'const int' error C2784: 'class std::complex<_Ty> __cdecl std::operator /(const class std::complex<_Ty> &,const class std::complex<_Ty> &)' : could not deduce template argument for 'const class st d::complex<_Ty> &' from 'const int' error C2677: binary '/' : no global operator defined which takes type 'class std::complex' (or there is no acceptable conversion) Error executing cl.exe. It also doesn't accept: complex c3 = 1 + i ; Any help is highly appreciated! Regards, Eliyah
It looks like
complex
is atemplate
class, and you have not supplied a required argument. My guess is the argument is the type used for the real and imaginary values:complex<double> complex_with_double_components;
complex<float> complex_with_float_components;I found this[^] on the MSDN; it should help.
Software Zen:
delete this;