complex in header file?

Discussion in 'C++' started by chuan, Apr 24, 2009.

  1. chuan

    chuan Guest

    #ifndef _GLUEBALL_H
    #define _GLUEBALL_H

    #include <complex>

    static const complex<int> gamma5[16] =
    { 0,0,1,0, 0,0,0,1, 1,0,0,0, 0,1,0,0 };

    #endif


    I have error during compiling:
    error: expected constructor, destructor, or type conversions before
    `<' token


    why????
     
    chuan, Apr 24, 2009
    #1
    1. Advertising

  2. chuan

    Guest

    On Apr 23, 4:40 pm, chuan <> wrote:
    > #ifndef _GLUEBALL_H
    > #define _GLUEBALL_H
    >
    > #include <complex>
    >
    > static const complex<int> gamma5[16] =
    >   { 0,0,1,0, 0,0,0,1, 1,0,0,0, 0,1,0,0 };
    >
    > #endif
    >
    > I have error during compiling:
    > error: expected constructor, destructor, or type conversions before
    > `<' token


    Bad error message from the compiler.
    http://www.comeaucomputing.com/tryitout/
    gives a much better one.

    You want std::complex. complex is a name in a namespace, so you need
    to do one of the following:
    using namespace std;
    using std::complex;
    std::complex

    Also, don't use names starting with underscores. All global names
    starting with underscores are reserved for the implementation (as are
    some other names in other scopes), so it's considered bad practice to
    ever use a name starting with an underscore, and in your case produces
    undefined behavior (?).
     
    , Apr 24, 2009
    #2
    1. Advertising

  3. In message
    <>,
    writes
    >On Apr 23, 4:40 pm, chuan <> wrote:
    >> #ifndef _GLUEBALL_H
    >> #define _GLUEBALL_H
    >>
    >> #include <complex>
    >>
    >> static const complex<int> gamma5[16] =
    >>   { 0,0,1,0, 0,0,0,1, 1,0,0,0, 0,1,0,0 };
    >>
    >> #endif
    >>
    >> I have error during compiling:
    >> error: expected constructor, destructor, or type conversions before
    >> `<' token

    >
    >Bad error message from the compiler.
    >http://www.comeaucomputing.com/tryitout/
    >gives a much better one.
    >
    >You want std::complex. complex is a name in a namespace, so you need
    >to do one of the following:
    > using namespace std;
    > using std::complex;
    > std::complex
    >
    >Also, don't use names starting with underscores. All global names
    >starting with underscores are reserved for the implementation (as are
    >some other names in other scopes), so it's considered bad practice to
    >ever use a name starting with an underscore, and in your case produces
    >undefined behavior (?).


    And what on earth are the semantics of std::complex<int> going to be?
    std::complex is only intended to be instantiated on floating-point
    types, or its behaviour will be so different from that of ordinary
    complex numbers that you should be calling it something else.

    26.2/2:

    The effect of instantiating the template complex for any type other than
    float, double or long double is unspecified.

    --
    Richard Herring
     
    Richard Herring, Apr 24, 2009
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. news.amnet.net.au
    Replies:
    1
    Views:
    605
    =?UTF-8?b?TMSByrtpZSBUZWNoaWU=?=
    Apr 13, 2004
  2. Stanimir Stamenkov
    Replies:
    2
    Views:
    795
    Stanimir Stamenkov
    Oct 25, 2005
  3. Robert Mark Bram
    Replies:
    0
    Views:
    718
    Robert Mark Bram
    Feb 4, 2007
  4. mlt
    Replies:
    2
    Views:
    916
    Jean-Marc Bourguet
    Jan 31, 2009
  5. Kottiyath

    How complex is complex?

    Kottiyath, Mar 18, 2009, in forum: Python
    Replies:
    22
    Views:
    802
Loading...

Share This Page