Path: utzoo!utgpu!news-server.csri.toronto.edu!rutgers!usc!snorkelwacker!mintaka!spdcc!ima!bbn.com!syswerda From: syswerda@bbn.com (Gilbert Syswerda) Newsgroups: comp.lang.c++ Subject: Borland's C++ memory allocation problems Message-ID: <59280@bbn.BBN.COM> Date: 4 Sep 90 20:54:09 GMT Sender: news@bbn.com Lines: 33 I have been having some problems with memory allocation using Borland's C++. The problems seem to reside with the way sizes of objects are computed. An example follows: //************************************************ #include class c { public: char a[65536]; } void main() { c b; printf ("Sizeof c: %ld\n", (long) (sizeof (c))); printf ("Sizeof b: %ld\n", (long) (sizeof (b))); printf ("Sizeof b.a: %ld\n", (long) (sizeof (b.a))); } **********OUTPUT************* Sizeof c: 2 Sizeof b: 2 Sizeof b.a: 65536 Doing a new() on an instance of class c results in only 2 bytes being allocated. I have tried using both the compact and huge memory models. I am new to both C and C++, so perhaps there is a simple misunderstanding on my part. Anyone have any suggestions?