Hi Conrad, Const member (non static) and reference members are initialized using the initializer list, e.g. myclass::myclass(Int_t newcount) : count(newcount) { // nothing to do anymore } Cheers, Maarten. On Fri, 2002-08-30 at 12:39, Conrad Steenberg wrote: > Hi > > On a related subject, what are the rules for initializing const members > outside the class definitions? My C++ books don't cover that very well > ;-) > > E.g. > > class myclass : public TObject { > public: > const Int_t count; > ... > } > > The following doesn't compile: > myclass::myclass(Int_t newcount){ > count=newcount; > } > > I thought you got once chance to initialize a const, and that the > constructor may be the place to do it, but this is obviously not the > case :-) > > Cheers! > > Conrad > > > > On Fri, 2002-08-30 at 06:40, Jiri Masik wrote: > > Mykulyak Andriy <A.Mykulyak@gsi.de> writes: > > > > > Hello, > > > > > > I wonder, why I cannot use consts as static class members. > > > > > > class TAFextPropHit : public TObject { > > > public: > > > static const Int_t kSignalCount = 8; > > > static const Float_t kScaleFactor = 1.5; > > > > > > TAFextPropHit(); > > > virtual ~TAFextPropHit(); > > > ... > > > > > > ClassDef(TAFextPropHit, 1) > > > ... > > > }; > > > > > > The class above will compile, but the shareable library built out of it will > > > not load into the ROOT runtime. > > > > > > > Hi, > > > > I think the initialization of a static data member should happen > > outside of the class definition > > > > class TAFextPropHit { > > public: > > static const Int_t kSignalCount; > > }; > > const Int_t TAFextPropHit::kSignalCount=8; > > > > What kind of error do you get? > > cheers > > Jiri > > > -- > *-----------------------------------------* > | Conrad Steenberg | > | Caltech, Mail Code 356-48 | > | Pasadena, CA, 91125 | > | e-mail: conrad@hep.caltech.edu | > | Tel: (626) 395-8758 | > *-----------------------------------------* -- Dr. Maarten Ballintijn MASSACHUSETTS INSTITUTE OF TECHNOLOGY Email: maartenb@mit.edu Room 24-410 Phone: +1 (617) 253 4184 77 Massachusetts Avenue Fax: +1 (617) 253 4360 Cambridge, MA 02139, USA http://www.mit.edu/~maartenb
This archive was generated by hypermail 2b29 : Sat Jan 04 2003 - 23:51:06 MET