Newsgroups: comp.lang.c++ Path: utzoo!censor!geac!alias!lfung From: lfung@alias.UUCP (Lisa A. Fung) Subject: Initializing an array class member? Message-ID: <1991Feb4.215231.16157@alias.uucp> Keywords: initializers constructors Sender: Lisa Fung, alias!lfung@csri.toronto.edu Organization: Alias Research Inc., Toronto ON Canada Date: Mon, 4 Feb 91 21:52:31 GMT What is the correct syntax for initializing an array class member? I have tried some combinations, all of which have resulted in syntax errors with the MacIntosh MPW C++ compiler. If you have an answer, please e-mail me. Also, if I happened to miss the answer in some C++ book or other, could you include the reference and page number? Here's my example: class myClass { public: myClass(); // constructor ~myClass(); // destructor private: Tthing arrayOfThings[3]; // Tthing's constructor takes an arg... }; // // The following attempt at initializing leads to a compile error... // myClass::myClass() : arrayOfThings[0]( arg), arrayOfThings[1]( arg), arrayOfThings[2]( arg) {} // // This attempt also leads to a compile error... // myClass::myClass() : arrayOfThings( Tthing( arg), TThing( arg), Tthing( arg)) {}