www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/11/30/07:17:33

From: Patrick Reilly <reillyp AT gte DOT net>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: Memory Problems
Date: 30 Nov 1997 11:29:10 GMT
Organization: gte.net
Lines: 41
Message-ID: <65rim6$i2g$2@gte2.gte.net>
References: <34805879 DOT 4FA AT unb DOT ca>
NNTP-Posting-Host: 1cust251.tnt1.columbia.mo.da.uu.net
Mime-Version: 1.0
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

I'd have to see some code. Biggest things are usually: don't skip error
checking (like text books do) - *know* that operator ::new() will throw
an xalloc object on error, or check the return value for null (its
almost always better to toss in the extra null check), and use an
initialization list for constructors so that when the body of the ctor
is entered all pointer members are valid (usually set to null).

Note that asking in a C++ user group would provide two things:

Lots of cat-calls and question-marks from people who have no idea, or
are not sure, what you mean by "initialization process", "attributes",
etc (or sound off for weeks about your terminology). I strongly suggest
learning the correct terminology - construction (or constructor, though
if you mean a constructor's initialization list that's a whole 'nother
kettle of fish), data members, member functions, etc. I assume that by
"initialization process" you mean construction, and that "attributes"
are data members...

I hope I don't sound like I'm flaming or something - I'm not. Without
the correct terminology its kinda like asking a surgeon about the "sharp
thing" - he may completely misunderstand what you want.

Pat



Neil Duxbury wrote:
> 
> I have the following problem in the C++ program I am writing using djgpp
> & rhide. Any help would be gratefully appreciated.
> 
> Neil
> 
> -------------
> 
> This problem occurs inside a class which has several attributes which
> are dynamically allocated. During the initialisation process of the
> class, many of these are initialised using the new command. Later on,
> when this class is used, another attribute is initialised with new. When
> this happens, one of the first group of attributes is "changed",
> basically containing nonsense values.

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019