Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!swrinde!elroy.jpl.nasa.gov!decwrl!fernwood!lia!steve From: steve@lia (Stephen Williams) Newsgroups: comp.lang.c++ Subject: Re: Constant data tables and classes Message-ID: <1991Apr8.041800.3757@lia> Date: 8 Apr 91 04:18:00 GMT References: <41062@genrad.UUCP> <20146@alice.att.com> Reply-To: steve@lia.com (Stephen Williams) Organization: Litton/Integrated Automation, Alameda, California Lines: 36 In article <20146@alice.att.com> bs@alice.att.com (Bjarne Stroustrup) writes: > > > > > I'm relatively new to C++, but have signifigant amounts of > > experience with C. It appears that C++ intentionally prohibits static > > const tables within classes. It would seem to me that allowing these > > would provide a convenient way of hiding constant data tables used by > > a class from outside use rather than using file scoped statics. Does > > anyoune know why this is disallowed? > >Is this what you want?: > > class X { > static const Table t; > // ... > }; > > const Table X::t = { /* lots of stuff */ }; > >If so, it works. The above works, but the following does not work in C++ 2.0: class X { int table[10]; // ... }; int X::table[10] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 }; This is quite frustrating. However, it works fine in C++ 2.1. (Yeah!) --Steve steve@lia.com