Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!milano.sw.mcc.com!cadillac!dsouza From: dsouza@optima.cad.mcc.com (Desmond Dsouza) Newsgroups: comp.lang.c++ Subject: Re: Sun C++ 2.0 - Default Argument Question Message-ID: Date: 25 Feb 91 23:10:47 GMT References: Sender: news@cadillac.CAD.MCC.COM Distribution: na Organization: MCC CAD Program, Austin, Texas Lines: 33 In-reply-to: leo@duttnph.tudelft.nl's message of 20 Feb 91 15:09:38 GMT In article leo@duttnph.tudelft.nl (Leo Breebaart) writes: > The thing is: we are trying to port a project from GNU g++ to Sun C++ > v. 2.0, and the following type of constructor > > SomeClass(String = "woppa"); > > generates a "sorry, not implemented: constructor needed for argument > initializer" error. (String is my own implementation of a String class.) > > My main problem is that for the life of me I cannot see a possible > workaround, and of course our code uses dozens of these constructors > (which GNU never had any trouble with). > > So: > > 1) Is using such a default argument a form of bad programming, and if so, > why? > > 2) If not, what can I possibly do to get my code running under Sun C++? Make String ("woppa") a static, private member inside SomeClass, and use that as a default in the constructor. > Leo Breebaart (leo @ duttnph.tudelft.nl) Desmond. -- ------------------------------------------------------------------------------- Desmond D'Souza, MCC CAD Program | ARPA: dsouza@mcc.com | Phone: [512] 338-3324 Box 200195, Austin, TX 78720 | UUCP: {uunet,harvard,gatech,pyramid}!cs.utexas.edu!milano!cadillac!dsouza