Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. complex numbers error

complex numbers error

Scheduled Pinned Locked Moved C / C++ / MFC
help
4 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • O Offline
    O Offline
    Oriented
    wrote on last edited by
    #1

    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

    B G 2 Replies Last reply
    0
    • O Oriented

      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

      B Offline
      B Offline
      BlackDice
      wrote on last edited by
      #2

      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

      O 1 Reply Last reply
      0
      • B 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

        O Offline
        O Offline
        Oriented
        wrote on last edited by
        #3

        no it doesn't work either!! Thanks

        1 Reply Last reply
        0
        • O Oriented

          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

          G Offline
          G Offline
          Gary R Wheeler
          wrote on last edited by
          #4

          It looks like complex is a template 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;

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups