Mail Archives: djgpp/1998/01/09/10:17:36
A. Jans-Beken wrote:
> As an exercise I made my own string class (from the book of Stroustrup).
> I wrote a testprogram too and it appears that the operator+= results in
> an abnormal program termination.
>
You didn't supply your += operator, so let me guess--you're not reallocating
your string when you change its length. When you get to the end of your
string buffer, you start overwriting memory that doesn't belong to you, with
"unpredictable and undesirable" results.
Take a look at your += operator, and make sure you're handling your memory
allocation correctly. You may find it useful to make a member method to
handle memory allocation and call it from all the appropriate places.
--
Charles Krug, Jr.
Application Engineer
Pentek Corp
1 Park Way
Upper Saddle River, NJ 07458
- Raw text -