Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!usc!cs.utexas.edu!sun-barr!ccut!wnoc-tyo-news!kogwy!new1!roger From: roger@zuken.co.jp (Roger Meunier) Newsgroups: comp.lang.c++ Subject: Re: Constant data tables and classes Message-ID: Date: 8 Apr 91 02:54:34 GMT References: <41062@genrad.UUCP> <20146@alice.att.com> Sender: news@new1.zuken.co.jp Organization: ZUKEN Inc. Yokohama, JAPAN Lines: 30 In-reply-to: bs@alice.att.com's message of 30 Mar 91 14:05:35 GMT In article <20146@alice.att.com> bs@alice.att.com (Bjarne Stroustrup) writes: Kyle Wilson (jkw@genrad.com) wrote: > > 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. How would you initialize the Table t for all instances in an array of class X, as in the following? X instanceList[20]; I'm finding it very hard to encapsulate such static tables (arrays of aggregates which I want to encapsulate in a C++ class) in C++. Has anyone arrived at an "elegant" solution? -- Roger Meunier @ Zuken, Inc. Yokohama, Japan (roger@zuken.co.jp)