Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!uunet!news.uu.net!taumet!steve From: steve@taumet.com (Stephen Clamage) Newsgroups: comp.lang.c++ Subject: Re: Derived/Base Class constructor relationship Message-ID: <743@taumet.com> Date: 22 May 91 16:09:28 GMT References: <29534@hydra.gatech.EDU> Distribution: na Organization: Taumetric Corporation, San Diego Lines: 36 gt5595c@prism.gatech.EDU (BARTZ) writes: >class A >{ > A(int f1,int f2,double first ...); // Constructor of base class > ... >}; >class B : public A >{ > B(int g1,double first ...) : Matrix(g1,g1,first) {}; > // Constructor for derived class > ... >}; >The constructor for the base class works OK with the ellipse >but the derived class construction does not work. The base class >constructor is not called with the list of doubles. I assume you meant B(int g1, double first ...) : A(g1, g1, first) {}; There is no syntax to support passing along a variable parameter list this way. Two solutions come immediately to mind: 1. Don't use variable parameter lists for the B constructor. Use an array of doubles and a count, for example, and add an A constructor which does the same: B::B(int g1, double *aray, int count) : A(g1, g1, aray, count) {} 2. Make A a member of B instead of deriving B from A. Then A can have an additional constructor taking a va_list parameter, and the B constructor can set up the va_list and invoke the A constructor. -- Steve Clamage, TauMetric Corp, steve@taumet.com