home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #26 / NN_1992_26.iso / spool / comp / lang / cplus / 16218 < prev    next >
Encoding:
Text File  |  1992-11-14  |  974 b   |  40 lines

  1. Path: sparky!uunet!destroyer!gatech!prism!federation!andy
  2. From: andy@federation.gatech.edu (Andy Register)
  3. Newsgroups: comp.lang.c++
  4. Subject: Re: how to initilize an array inside of a class??
  5. Message-ID: <74710@hydra.gatech.EDU>
  6. Date: 13 Nov 92 15:54:36 GMT
  7. References: <BxL3t2.FKG@ns1.nodak.edu> <1992Nov12.184605.1@vax1.bham.ac.uk> <BxnAuM.51w@cs.vu.nl>
  8. Sender: news@prism.gatech.EDU
  9. Organization: CERL-EE, Georgia Institue of Technology
  10. Lines: 28
  11.  
  12. As long as there is no ctor or dtor, you could do:
  13.  
  14. // ***************************************************************
  15. #include<iostream.h>
  16. #include<stdio.h>
  17.  
  18. class X {
  19.   public:
  20.     enum {ARR_SIZE=10};
  21.     int SomeInts[ARR_SIZE];
  22.     void Write();
  23. };
  24.  
  25. void X::Write()
  26. {
  27.     for (int i=0 ; i < ARR_SIZE ; i++)
  28.         cout << SomeInts[i] << "  ";
  29.     cout << endl;
  30. }
  31.  
  32. void main() {
  33.   X Some = {10, 20, 30, 40, 50, 100, 90, 80, 70, 60};
  34.   Some.Write();
  35. }
  36. // ***************************************************************
  37.  
  38. Toodles
  39. Andy
  40.