Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!wuarchive!uunet!taumet!steve From: steve@taumet.com (Stephen Clamage) Newsgroups: comp.lang.c++ Subject: Re: Accessing base class constructors Message-ID: <765@taumet.com> Date: 13 Jun 91 17:02:10 GMT References: <1991Jun12.183837.15084@bmw.mayo.edu> Organization: Taumetric Corporation, San Diego Lines: 28 bmc@mayo.edu (Bruce Cameron) writes: >Being a novice to C++, I do not understand why I am unable to access a >base class' constructor from a derived class... >Yet when I try to do this with a base class that makes use of a vararg >list I get a variety of syntax errors (using Sun C++2.1). Is it >possible to have a base class constructor with a vararg list and >derive classes from it that initialize the base class through its >constructor? If not, any work arrounds for this? How are these >supposed to work? You can't do it. There is no syntax to support just passing along a variable argument list to any function, constructor or not. You have to use the facilities in or . Some workarounds: 1. Don't use varargs in the constructor. Pass an array of args, either with a separate "count" argument, or a designated termination value at the end of the array (like NULL for an array of pointers). 2. Write an auxiliary private 'init' function called from constructors. It takes a va_alist parameter. The constructor sets up the va_alist and passes it to the init function. -- Steve Clamage, TauMetric Corp, steve@taumet.com