Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > complex in header file?

Reply
Thread Tools

complex in header file?

 
 
chuan
Guest
Posts: n/a
 
      04-23-2009
#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????
 
Reply With Quote
 
 
 
 
joshuamaurice@gmail.com
Guest
Posts: n/a
 
      04-23-2009
On Apr 23, 4:40*pm, chuan <(E-Mail Removed)> 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 (?).
 
Reply With Quote
 
 
 
 
Richard Herring
Guest
Posts: n/a
 
      04-24-2009
In message
<(E-Mail Removed)>,
http://www.velocityreviews.com/forums/(E-Mail Removed) writes
>On Apr 23, 4:40*pm, chuan <(E-Mail Removed)> 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
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How complex is complex? Kottiyath Python 22 03-28-2009 10:11 PM
Header files with "header.h" or <header.h> ?? mlt C++ 2 01-31-2009 02:54 PM
wsdl2java: method parameter a complex type that extends another complex type Robert Mark Bram Java 0 02-04-2007 10:06 AM
[XML Schema] Content type of complex type definition with complex content Stanimir Stamenkov XML 2 10-25-2005 10:16 AM
For expert on complex loops (reposted) - complex looping problem news.amnet.net.au Java 1 04-13-2004 07:10 AM



Advertisments