Boost logo

Boost :

From: Jonathan Wakely (cow_at_[hidden])
Date: 2004-05-27 09:47:20


On Thu, May 27, 2004 at 04:06:19PM +0200, Dr. Franz Fehringer wrote:

> > Joaqu?n M? L?pez Mu?oz wrote:
> .
> .
> .
> > Good question. I should have explained of course.
> > Well vacpp has only in some circurmstances a problem with the in class
> > member initialization. For instance following does not work (confirmed
> > by IBM):
> >
> > class A
> > {
> > public:
> > static const int value = true ;
> > } ;
> >
> > int main()
> > {
> > int v1 = A::value ; // does work
> > bool v2 = A::value ; // does not work
> > return 0 ;
> > } ;
>
> Hello,
>
> I know i argue with eminent C++ specialists in this group, but i think the
> code above is not correct.
> To my best knowledge even with the inclass line
> static const int value = true ;
> you have to give a definition outside of the class:
> int A::value;

Only if A::value is "used in the program". Stroustrup says if you use it in
a way that requires the object to be stored in memory, e.g take its address

AFAICT you don't need to give an out-of-class definition if the value is only
used in integral constant expressions. Is that right?

> Apart from that
> return 0;
> should be unnecessary

But it isn't incorrect.

jon

-- 
Emacs is a nice OS - but it lacks a good text editor.
That's why I am using Vim.
	- Anonymous

Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk