Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!uunet!seismo!rochester!crowl From: crowl@rochester.arpa (Lawrence Crowl) Newsgroups: comp.lang.c++ Subject: Re: complex arrays Message-ID: <1053@sol.ARPA> Date: Tue, 4-Aug-87 11:57:05 EDT Article-I.D.: sol.1053 Posted: Tue Aug 4 11:57:05 1987 Date-Received: Thu, 6-Aug-87 01:43:47 EDT References: <3400003@uicsgva> Reply-To: crowl@rochester.UUCP (Lawrence Crowl) Organization: U of Rochester, CS Dept, Rochester, NY Lines: 37 In article <3400003@uicsgva> rahmeh@uicsgva.UUCP writes: >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 > >If you have an explanation please let me know. The C++ compiler implements initialization of class instance elements within an array by passing the address of the class constructor to another routine which loops though the elements. Since the looping routine has no knowledge of the constructor, it requires that the constructor take no parameters. The definition of the class complex in complex.h shows one constructor taking two parameters. True, the parameters are defaulted, but the constructor still takes two parameters. This the source of the error. This can be fixed by changing part of the class definition from: complex(double r = 0.0, double i = 0.0) { re=r; im=i; } to: complex() { re=0.0; im=0.0; } complex(double r, double i = 0.0) { re=r; im=i; } Keepers of the compiler (or library), can you make this update? -- Lawrence Crowl 716-275-8479 University of Rochester crowl@cs.rochester.arpa Computer Science Department ...!{allegra,decvax,seismo}!rochester!crowl Rochester, New York, 14627