This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: How do I create/initialize a large class static (const?) array?


Lee Rhodes wrote:

> I need to create a class static (const?) array and then initialize it once
> when the first instance of the class is declared after which it should never
> be modified, only read.  This array is too large to use the array {...}
> initializer syntax.  I need to initialize the array with an algorithm.
> 
> The following obviously does not work, but I'm not sure how to do it. (It is
> very easy in Java!)

This is a C++ language issue and not a gcc issue.  A good book on C++
should explain why the code fails -- static data members must be defined
in exactly one unit.  This page (and the rest of the site) is a good
resource: http://www.parashift.com/c++-faq-lite/ctors.html>.  It
describes several ways of solving the problem you describe.

Brian


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]