cohler@batcomputer.UUCP (07/07/86)
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
}