home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.c++
- Path: sparky!uunet!charon.amdahl.com!pacbell.com!ames!elroy.jpl.nasa.gov!swrinde!cs.utexas.edu!convex!news.utdallas.edu!corpgate!bnrgate!bnr.co.uk!pipex!warwick!bham!bhamvx!mccauleyba
- From: mccauleyba@vax1.bham.ac.uk (Brian McCauley)
- Subject: Re: how to initilize an array inside of a class??
- Sender: usenet@rs6000.bham.ac.uk (USENET News Service)
- Message-ID: <1992Nov12.184605.1@vax1.bham.ac.uk>
- Date: Thu, 12 Nov 1992 18:46:05 GMT
- Lines: 35
- References: <BxL3t2.FKG@ns1.nodak.edu>
- Organization: University of Birmingham
-
- In article <BxL3t2.FKG@ns1.nodak.edu>, cooper@plains.NoDak.edu (Jeff Cooper) writes:
- [ example class with array member ]
- > Now what I'd need to do is initilize the array 'some_ints' with some
- > preset values...normally one would do it like:
- >
- > int some_ints[3000] = { 1, 6, 34, 3, ... ,0 };
- >
- > But my compiler complains about that, saying that I can't initialize
- > class members there. The only other way I can think of doing it is
- > to do something like:
- >
- > Y::Y()
- > {
- > some_ints[0] = 1;
- > some_ints[1] = 6;
- > ...
- > some_ints[2999] = 0;
- > }
- >
- > Is this my only other option??
- Yes I'm afraid it is. I asked a very similar question to this last week. I
- would like to see the array handling in C++ tidied up a bit, but the weight of
- oppinion is against me. If I had my way you would be able to say:
- Y::Y() {some_ints={1,6, ... 0}; }
- or
- Y::Y() : some_ints({1,6,...0}) {}
- but nobody seems to support me.
- --
- \\ ( ) NO BULLSHIT! from BAM (Brian McCauley)
- . _\\__[oo
- .__/ \\ /\@ E-mail: B.A.McCauley@bham.ac.uk
- . l___\\ Fax: +44 21 625 2175
- # ll l\\ Snail: 197 Harborne Lane, Birmingham, B29 6SS, UK
- ###LL LL\\ ICBM: 52.5N 1.9W
-
-