Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!watmath!clyde!burl!ulysses!bellcore!decvax!decwrl!pyramid!hplabs!tektronix!uw-beaver!cornell!batcomputer!cohler From: cohler@batcomputer.UUCP Newsgroups: net.lang.c++ Subject: Arrays of Classes Message-ID: <566@batcomputer.TN.CORNELL.EDU> Date: Mon, 7-Jul-86 16:42:55 EDT Article-I.D.: batcompu.566 Posted: Mon Jul 7 16:42:55 1986 Date-Received: Thu, 10-Jul-86 01:06:38 EDT Organization: Theory Center, Cornell U., Ithaca NY Lines: 43 Keywords: arrays, classes, complex Machine : c++ on vax/750 running BSD 4.2 a Bug ? We have encountered a problem with allocating storage for arrays of classes. Looking at the generated c code it seems that 'new' forgets to cast '_vec_new()'. Has anyone else had similar problems ? The following code illustrates the problem - which goes away by compiling with -DBUGFIX. Also complex.h does not have a default constructor - so arrays of complex numbers cant be defined at all - this of course can be fixed by providing a default constructor in complex.h. Gene Cohler cohler@lnsvax.tn.cornell.EDU Newman Lab, Cornell Univ jbvy@cornella.BITNET Ithaca NY 14853-5001 {decvax,ihnp4,cmcl2,vax135} !cornell!lnsvax!cohler ======================= source code ====================== // tst.c -> Arrays of classes ? class test { public: int i1; int i2; test(){i1 = 0; i2 = 0;} }; main() { test *t1 ; #ifdef BUGFIX t1 = (struct test *) new test[10] ; #else t1 = new test[10] ; #endif BUGFIX }