home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #26 / NN_1992_26.iso / spool / comp / lang / cplus / 16172 < prev    next >
Encoding:
Text File  |  1992-11-12  |  1.7 KB  |  47 lines

  1. Newsgroups: comp.lang.c++
  2. 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
  3. From: mccauleyba@vax1.bham.ac.uk (Brian McCauley)
  4. Subject: Re: how to initilize an array inside of a class??
  5. Sender: usenet@rs6000.bham.ac.uk (USENET News Service)
  6. Message-ID: <1992Nov12.184605.1@vax1.bham.ac.uk>
  7. Date: Thu, 12 Nov 1992 18:46:05 GMT
  8. Lines: 35
  9. References: <BxL3t2.FKG@ns1.nodak.edu>
  10. Organization: University of Birmingham
  11.  
  12. In article <BxL3t2.FKG@ns1.nodak.edu>, cooper@plains.NoDak.edu (Jeff Cooper) writes:
  13.  [ example class with array member ] 
  14. > Now what I'd need to do is initilize the array 'some_ints' with some
  15. > preset values...normally one would do it like:
  16. > int some_ints[3000] = { 1, 6, 34, 3, ... ,0 };
  17. > But my compiler complains about that, saying that I can't initialize
  18. > class members there.  The only other way I can think of doing it is
  19. > to do something like:
  20. > Y::Y()
  21. > {
  22. >     some_ints[0] = 1;
  23. >     some_ints[1] = 6;
  24. >     ...
  25. >     some_ints[2999] = 0;
  26. > }
  27. > Is this my only other option??
  28. Yes I'm afraid it is. I asked a very similar question to this last week. I
  29. would like to see the array handling in C++ tidied up a bit, but the weight of
  30. oppinion is against me. If I had my way you would be able to say:
  31. Y::Y() {some_ints={1,6, ... 0}; }
  32. or 
  33. Y::Y() : some_ints({1,6,...0}) {}
  34. but nobody seems to support me.
  35. -- 
  36.     \\   ( )  NO BULLSHIT! from BAM (Brian McCauley)
  37.  .  _\\__[oo 
  38. .__/  \\ /\@  E-mail: B.A.McCauley@bham.ac.uk
  39. .  l___\\        Fax: +44 21 625 2175
  40.  # ll  l\\     Snail: 197 Harborne Lane, Birmingham, B29 6SS, UK
  41. ###LL  LL\\     ICBM: 52.5N 1.9W
  42.  
  43.