Thread: Trying to use complex.h classes, some keyword is hiding it

  1. #1
    Ethernal Noob
    Join Date
    Nov 2001
    Posts
    1,901

    Trying to use complex.h classes, some keyword is hiding it

    I'm trying to implement a calculation which involves a sqare root and therefore has the possibility of becoming a complex number. I found that C++ has a standard complex number class which would work rather well, with multiplication and all. The only problem is somehow another keyword called complex is hiding the implementation, even when I try to use "std::complex" it says this error.

    Code:
    error: `complex' undeclared (first use this function)
    error: (Each undeclared identifier is reported only once for each function it appears in.)
    error: expected `;' before "a"
    Anyone know how I can solve this?

  2. #2
    coder
    Join Date
    Feb 2008
    Posts
    127
    May you post the interesting part of your code?

  3. #3
    Ethernal Noob
    Join Date
    Nov 2001
    Posts
    1,901
    never mind, I thought it was an updated C library, but it uses standard templates. I just needed to give it a template argument.

  4. #4
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    28,413
    By the way, remember that the header is <complex>, not <complex.h>.
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  5. #5
    Ethernal Noob
    Join Date
    Nov 2001
    Posts
    1,901
    yeah.

    Man I didn't even know some of these classes existed.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Can you Initialize all classes once with New?
    By peacerosetx in forum C++ Programming
    Replies: 12
    Last Post: 07-02-2008, 10:47 AM
  2. Multiple Inheritance - Size of Classes?
    By Zeusbwr in forum C++ Programming
    Replies: 10
    Last Post: 11-26-2004, 09:04 AM
  3. im extreamly new help
    By rigo305 in forum C++ Programming
    Replies: 27
    Last Post: 04-23-2004, 11:22 PM
  4. Exporting VC++ classes for use with VB
    By Helix in forum Windows Programming
    Replies: 2
    Last Post: 12-29-2003, 05:38 PM
  5. Prime Number Generator... Help !?!!
    By Halo in forum C++ Programming
    Replies: 9
    Last Post: 10-20-2003, 07:26 PM