Static member initialization

From: Agoston Bejo (gusz1_at_freemail.hu)
Date: 01/04/05


Date: Tue, 4 Jan 2005 18:19:37 +0100

Hello there,
is it possible to initialize such a static member that need some algorithm
for

initializing? What I mean is:

----------------------------------
Example: Platform VC++7.1
----------------------------------
#include <iostream>

using namespace std;

struct A {
 static int ia[10];
}

for(int i=0;i<10;++i) { A::ia[i] = i; } // SYNTAX ERROR: 'for'

int _tmain(int argc, _TCHAR* argv[])
{
 cout << A::ia[5] << endl;
 return 0;
}

---------------------------------

What is actually missing is a kind of "static constructor" for a class, sort
of

like in Java.

Any ways to do this?

Thx,
Agoston



Relevant Pages

  • Re: NULL and zeros
    ... I assume the target platform can run X ... *hypothetical* portability more important than convenience in my ... If you want to initialize a struct without knowing what elements ...
    (comp.lang.c)
  • Static member initialization
    ... is it possible to initialize such a static member that need some algorithm ... Example: Platform VC++7.1 ... using namespace std; ... struct A { ...
    (comp.lang.cpp)
  • Re: How to add activesync to my headless platform?
    ... I have tried to create a display-based platform ... initialize the notification subsytem in this case. ... ActiveSync really needs the user interface (it shows a dialog ...
    (microsoft.public.windowsce.platbuilder)
  • Re: Weird pointer error
    ... > assign values to pointers when I don't initialize them. ... The contents of your application's memory (which could determine ... so your antics did not cause the platform to complain. ...
    (comp.lang.cpp)
  • Re: linked list (c programming)
    ... >> similar, after you allocate the memory, to get it into a known state ... > platform, it will probably work, but that's not the same thing as being ... known state' using memset or similar - not 'initialize it to useful starting ... allocated memory invites a whole slew of interesting, ...
    (comp.programming)