Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!uunet!munnari!otc!mikem From: mikem@otc.OZ (Mike Mowbray) Newsgroups: comp.lang.c++ Subject: Re: complex arrays Message-ID: <157@otc.OZ> Date: Tue, 4-Aug-87 19:40:21 EDT Article-I.D.: otc.157 Posted: Tue Aug 4 19:40:21 1987 Date-Received: Fri, 7-Aug-87 06:44:12 EDT References: <3400003@uicsgva> Organization: O.T.C. Systems Development, Australia Lines: 51 In article <3400003@uicsgva>, rahmeh@uicsgva.UUCP says: > > The following program: > > #include > main() > { > complex a[2]; > } > > causes the C++ compiler to produce the following error > message: > > line 5: sorry, not implemented: default arguments > for constructor for vector of class complex The problem is that cfront doesn't yet have a good way to pass arbitrary arguments into a function that initialises arrays of user-defined objects. The fix involves creating a complex constructor that takes no arguments. Alter so that there are two constructors instead of one. The standard version looks like: class complex { double re, im; public: complex(double r = 0.0, double i = 0.0) { re = r; im = i; } // ..... }; Change it to: class complex { double re, im; public: complex() { re = im = 0.0; } complex(double r, double i = 0.0) { re = r; im = i; } // ..... }; The above program then compiles happily. Mike Mowbray Systems Development |||| OTC || ACSnet: mikem@otc.oz UUCP: {seismo,mcvax}!otc.oz!mikem Phone: (02) 287-4104 Snail: GPO Box 7000, Sydney 2001, Australia