🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: alt.comp.lang.learn.c-c++
Article #362

Re: Arrays as static members

#362
From: Chris Newton
Date: Fri, 02 Jul 1999 00:00
25 lines
1468 bytes
Magnus Hult wrote...
>I've got a problem (again). Take a look at this:
>
>class Object {
>    public:
>        int id;
>        static Object *pId[50];
>};
>
>How to allocate memory for those 50 static members? I can't make a loop
>outside a function, and it doesn't feel right to write "Object
>*Object::pId[n] = 0;" 50 times.


I don't quite see the problem.  You certainly can initialize or assign to
the pId array using a loop anywhere where you could do it with 50 nearly
identical lines of code.  Where do you want to make this assignment - in a
member function of class Object, in a function which is not a method of
Object, somewhere else?

Regards,
Chris

--
Please reply to this newsgroup. To mail me privately, lose the "spamfree".
Technical Details
Message-ID: <7lgtle$1c8$1@pegasus.csx.cam.ac.uk>
Path: arc1-ca.pugleaf.net!unknown!not-for-mail
References: <qQQe3.1601$nZ5.3455@nntpserver.swip.net>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: f8d38,aecd7aaa6e14dde4
X-Google-Attributes: gidf8d38,public
X-Google-Thread: 109fba,aecd7aaa6e14dde4
X-Google-Attributes: gid109fba,public
X-Google-Thread: 114592,aecd7aaa6e14dde4
X-Google-Attributes: gid114592,public
From: "Chris Newton" <can21@spamfree.cam.ac.uk>
Subject: Re: Arrays as static members
Date: 1999/07/02
Message-ID: <7lgtle$1c8$1@pegasus.csx.cam.ac.uk>
X-Deja-AN: 496208882
References: <qQQe3.1601$nZ5.3455@nntpserver.swip.net>
Organization: University of Cambridge, England
X-MimeOLE: Produced By Microsoft MimeOLE V4.72.3155.0
Newsgroups: alt.comp.lang.learn.c-c++,borland.public.cpp.language,comp.lang.c++