home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!destroyer!gatech!prism!federation!andy
- From: andy@federation.gatech.edu (Andy Register)
- Newsgroups: comp.lang.c++
- Subject: Re: how to initilize an array inside of a class??
- Message-ID: <74710@hydra.gatech.EDU>
- Date: 13 Nov 92 15:54:36 GMT
- References: <BxL3t2.FKG@ns1.nodak.edu> <1992Nov12.184605.1@vax1.bham.ac.uk> <BxnAuM.51w@cs.vu.nl>
- Sender: news@prism.gatech.EDU
- Organization: CERL-EE, Georgia Institue of Technology
- Lines: 28
-
- As long as there is no ctor or dtor, you could do:
-
- // ***************************************************************
- #include<iostream.h>
- #include<stdio.h>
-
- class X {
- public:
- enum {ARR_SIZE=10};
- int SomeInts[ARR_SIZE];
- void Write();
- };
-
- void X::Write()
- {
- for (int i=0 ; i < ARR_SIZE ; i++)
- cout << SomeInts[i] << " ";
- cout << endl;
- }
-
- void main() {
- X Some = {10, 20, 30, 40, 50, 100, 90, 80, 70, 60};
- Some.Write();
- }
- // ***************************************************************
-
- Toodles
- Andy
-