Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!swrinde!mips!samsung!uunet!huxley!glenn From: glenn@bitstream.com (Glenn P. Parker) Newsgroups: comp.lang.c++ Subject: Re: const in a class Message-ID: Date: 18 Jun 91 13:33:29 GMT References: <1991Jun17.184324.1979@demon.co.uk> Sender: glenn@huxley.UUCP Reply-To: (Glenn Parker) Distribution: comp Organization: Bitstream, Inc. Lines: 30 In-reply-to: gtodd@cix.compulink.co.uk's message of 17 Jun 91 18:43:24 GMT In article <1991Jun17.184324.1979@demon.co.uk> gtodd@cix.compulink.co.uk (Giles Todd) writes: > steve@taumet.com (Stephen Clamage) writes: > > Unfortunately, this is not supported in C++. The best you can do > > is to declare an enum: > > class C { > > enum { size = 1000 }; > > char array[size]; > > ... > > }; > > Careful here. The value of an enumerator must be an int or a value that > can be promoted to int by integral promotion. If the compiler implementor > has decided to represent enums with chars then your example will overflow > (perhaps silently). For safety's sake, limit the values of enums to the > range 0..127. This would be *awful* if it were true. Fortunately, such paranoia is completely unjustified. A compiler [implementor] is allowed to represent a particular enum type with the smallest word-size necessary to represent *all* valid values for the enum. So, there should be absolutely no danger in having an enum type with a value outside the range 0..127. If your compiler fails this test, send it back. -- Glenn P. Parker glenn@bitstream.com Bitstream, Inc. uunet!huxley!glenn 215 First Street BIX: parker Cambridge, MA 02142-1270