Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!swrinde!elroy.jpl.nasa.gov!decwrl!mcnc!beguine!Brian.Chan From: Brian.Chan@samba.acs.unc.edu (Brian Chan) Newsgroups: comp.lang.c++ Subject: Constructor and class initialization w/ arrays Keywords: How do you do it? Message-ID: <3118@beguine.UUCP> Date: 27 Mar 91 13:35:36 GMT Sender: usenet@beguine.UUCP Lines: 55 Can someone help me with a beginner's question? 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) { ... } If I declare B b1(1,1,1), b2(2,2,2), no problem. But if I want to declare a table (array) of Bs, say , 2, how do I do it? I tried the following: B b[] = { {1, 1, 1}, {2, 2, 2}}; // won't work B b[2]; // won't work obviously The only way I could make the array method to work was to declare (void) in the constructors, and create some member functions say, create(int, int, int) within A and B. It looks pretty ugly. Any toughts or hints? Thx very much for your time in advance, Brian Chan. Stuttgart, FRG -- ============================================================================= Extended Bulletin Board Service, Research & Development Office of Information Technology, University of North Carolina at Chapel Hill internet: bbs.acs.unc.edu or 128.109.157.30