Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!swrinde!elroy.jpl.nasa.gov!decwrl!world!wmm From: wmm@world.std.com (William M Miller) Newsgroups: comp.lang.c++ Subject: Re: AT&T ODE Message-ID: <1991Mar24.205053.10106@world.std.com> Date: 24 Mar 91 20:50:53 GMT References: <27EC1A78.14249@maccs.dcss.mcmaster.ca> Organization: The World Public Access UNIX, Brookline, MA Lines: 34 cui@maccs.dcss.mcmaster.ca (Jun Cui) writes: > class test { > const int foo = 10; > // other .... > } > > When compiling it using AT&T Concurrent C++, I was given a message > 'error: initializer for member test::foo'. > AT&T Concurrent C++ uses a different way to initialize a constant? Any C++ compiler should reject that; it's not legal C++. Even for int constants, the only way to initialize them is via the constructor's initialization list: class foo { const int i; foo(); //... }; foo::foo(): i(10) { } Of course, that means you can't use constant members for things like array bounds and the like, where a constant expression is required. For that, you can use an enumeration constant: class bar { enum { ARRAY_SIZE = 100 }; int array[ARRAY_SIZE]; //... }; -- William M. Miller, Glockenspiel, Ltd. wmm@world.std.com