Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > C - C++ Learning > static constant...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 1 of 5 Topic 4263 of 4370
Post > Topic >>

static constant - non integral type

by forums_mp@[EMAIL PROTECTED] Sep 7, 2008 at 07:06 AM

// header file called .. test.h                 [1]
static const double dval ( 3.1233 );

// in a source file called main.cpp        [2]
class  bar {
  static const double dbar_val ;
public :
  bar () {}
};
double bar::dbar_val = 3.1233;


[1] compiles while [2] does not because only (hope I'm saying this
right) static const integral data members can be initialized in a
class.  I was reading a thread a few days ago where it was said - if
memory serves - C++Ox (some version of GCC is already doing this) will
recognize [2].  The question: Why is [1] allowed to compile while [2]
doesnt?  The fact that one is a class and the other is not doesnt seem
like a good answer to me.
 




 5 Posts in Topic:
static constant - non integral type
forums_mp@[EMAIL PROTECTE  2008-09-07 07:06:39 
Re: static constant - non integral type
"Alf P. Steinbach&qu  2008-09-07 16:13:15 
Re: static constant - non integral type
forums_mp@[EMAIL PROTECTE  2008-09-07 07:19:23 
Re: static constant - non integral type
"Alf P. Steinbach&qu  2008-09-07 16:32:08 
Re: static constant - non integral type
jhendrix58 <jhendrix58  2008-09-09 15:16:45 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Fri Nov 21 13:39:20 CST 2008.