Article View: de.comp.lang.c++
Article #2148Re: How initialize static member arrays?
From: Nepomuck
Date: Tue, 16 Apr 1996 18:33
Date: Tue, 16 Apr 1996 18:33
58 lines
1554 bytes
1554 bytes
Bernhard Ruch (Bernhard.Ruch@studi.epfl.ch) wrote:
: Karl-Heinz Krause wrote:
: > > How can I initialize an array that is a static member
: > > of a class?
: >
: > > e.g.
: >
: > > class A {
: > > private:
: > > static int stat_int[20];
: > > };
: >
: > Kein Problem:
: >
: > class A {
: > static int stat_int[20];
: > };
: >
: > int A::stat_int[] = { 1, 2, 3, 4 };
: >
: > Karl-Heinz Krause
: Ok, dies geht sehr gut fuer ein Array der Groesse 20,
: aber was macht man, wenn man ein Array der Groesse 50000
: initialisieren muss?
Warum nimmst Du nicht eine static member function:
class A {
private:
static int stat_int[20];
public:
static void init_stat_int();
}
In der Implementation von "init_stat_int" schreibst Du Deine Initialisierungs-
code, und mit
A::init_stat_int();
rufst Du die Funktion auf (ohne, dass Du eine Instanz der Klasse A bilden
musst).
- Michael -
: EPFL-Info 97
Technical Details
Message-ID:
<4l0p5o$pri@h20-hrze.uni-duisburg.de>Path:
arc1-ca.pugleaf.net!e45-hrze.uni-duisburg.de!sg102neReferences:
<4kg90n$2c9@netlab.cs.rpi.edu> <4kjghq$pqa@news00.btx.dtag.de> <31720552.2781@studi.epfl.ch>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!e45-hrze.uni-duisburg.de!sg102ne From: sg102ne@e45-hrze.uni-duisburg.de (Nepomuck) Newsgroups: de.comp.lang.c++ Subject: Re: How initialize static member arrays? Date: 16 Apr 1996 18:33:28 GMT Organization: Gerhard-Mercator-Universitaet - Gesamthochschule Duisburg Distribution: world Message-ID: <4l0p5o$pri@h20-hrze.uni-duisburg.de> References: <4kg90n$2c9@netlab.cs.rpi.edu> <4kjghq$pqa@news00.btx.dtag.de> <31720552.2781@studi.epfl.ch> NNTP-Posting-Host: e45-hrz.uni-duisburg.de X-Newsreader: TIN [version 1.2 PL2]