How do I create/initialize a large class static (const?) array?
Brian Dessent
brian@dessent.net
Mon Aug 13 04:57:00 GMT 2007
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
More information about the Gcc-help
mailing list