Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!samsung!uunet!taumet!steve From: steve@taumet.com (Stephen Clamage) Newsgroups: comp.lang.c++ Subject: Re: Constructor and class initialization w/ arrays Keywords: How do you do it? Message-ID: <642@taumet.com> Date: 28 Mar 91 16:59:50 GMT References: <3118@beguine.UUCP> Organization: Taumetric Corporation, San Diego Lines: 19 Brian.Chan@samba.acs.unc.edu (Brian Chan) writes: >Say I have the following declarations: >Class A: { int a; int b; } >Class B: public A { ... } >And constructors: >Class A::A(int x, int y) { } >Class B::B(int z, int x, int y) :A(x, y) { ... } > ... >But if I want to declare a table (array) of Bs, say , 2, how do I do it? You cannot declare an array of class objects using other than the default (no parameters) constructor. There is no syntax to support it. You can declare a constructor with all default parameters standing in for the default constructor, and that one will be used. That's the best you can do. (This last is a language change, and works with recent C++ compilers.) -- Steve Clamage, TauMetric Corp, steve@taumet.com