CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Apr 1999
    Location
    The Netherlands
    Posts
    1

    Problems with Complex Math in C++

    I'm new to C and C++ programming and I've chosen MS VC++ V6.0 for my
    work. The question that I have is:

    How do I declare complex variables, arrays and functions in C++ V6.0?
    I understand that I need to include the appropriate header file in my source code. I do this using:

    #include <complex>



    Everything that I've tried has failed.
    By the way, at this time I'm just trying to implement a simple console
    program.




  2. #2
    Join Date
    Apr 1999
    Location
    CA, USA
    Posts
    78

    Re: Problems with Complex Math in C++

    You need to make the complex into the namespace, for example:
    #include <complex>
    using namespace std;

    //......
    complex<double> d1(10, 5), d2(5, 10);
    d1 += d2; // d1.real() = 15, d1.imag() = 15
    //........

    Hope this will help. Good luck.

    Lynx



Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured