Path: utzoo!mnetor!tmsoft!torsqnt!geac!alias!barney!rae From: rae@utcs.toronto.edu (Reid Ellis) Newsgroups: comp.lang.c++ Subject: Re: Initializing an array class member? Keywords: initializers constructors Message-ID: Date: 6 Feb 91 22:15:02 GMT References: <1991Feb4.215231.16157@alias.uucp> <586@taumet.com> Sender: Reid Ellis Reply-To: Reid Ellis Organization: Alias Research, Inc. Toronto ON Canada Lines: 36 lfung@alias.UUCP (Lisa A. Fung) writes: >class myClass { > public: > myClass(); // constructor > ~myClass(); // destructor > private: > Tthing arrayOfThings[3]; // Tthing's constructor takes an arg... >}; The above is a class containing an array. steve@taumet.com (Stephen Clamage) writes: >struct T1 { T1(int); }; // no default constructor >struct T2 { T2(); T2(int); }; // has a default constructor > >T1 a[3]; // illegal, no default constructor to call >T1 b[3] = { T1(1), T1(2), T1(3) }; // ok > >T2 c[3]; // ok, uses default constructor >T2 d[3] = { T2(1), T2(2), T2(3) }; // ok The above is an array of class objects. This still doesn't answer the question. How do you write T1::T1() if you have an array *IN THE CLASS*. i.e.: struct T1 { T1(); int a[10]; } T1::T1() : a(???) { } What do you put for "???"? Reid -- Reid Ellis 176 Brookbanks Drive, Toronto ON, M3A 2T5 Canada rae@gpu.utcs.toronto.edu || rae%alias@csri.toronto.edu CDA0610@applelink.apple.com || +1 416 446 1644