Contents of the STRING.TXT file
A String Class For C++
25 October, 1989
Scott Robert Ladd
705 West Virginia
Gunnison CO 81230
BBS: (303) 641-5125
Legal Disclaimer (Yuck)
The software presented in this package is public domain. You
may do anything you please with this software. As such,
there are no warranties or guarantees whatsoever as to the
quality, suitability, or general functionality of this
software. If you use this software, you accept full
responsibility for what it does or doesn't do.
Personally, I hate these disclaimers; however, in the
litigious world we live in, you can't even give something
away for free without covering yourself. Frankly, I suspect
most people are generally appreciative that I've made this
stuff available to them.
This software was developed using Zortech's C++ v2.00 on a
20Mhz 80386-based PC running MS-DOS 3.30. It should work
with all C++ compilers, since it contains nothing which is
Zortech or MS-DOS specific.
One last request: if you do use this class, I'd like to hear
from you. I'm interested in any changes you might make. If
you find any bugs (!), drop me a line, and I'll see what I
can do. Again, since this is free, I can't make any
guarantees about how quickly any bug will get fixed. But I
will do my best!
This document should be part of an archived package, which
contains a complete C++ class for handling dynamically-
allocated strings. Included in the package should be:
STRING.TXT -- this document!
STRING.HPP -- the string class header file
STRING.CPP -- the string class implementation
STRTST.CPP -- A program which uses Strings
If you do redistribute this code, please do so with all of
the files together in an archive. While I use LHARC to
distribute this package, you can use any archiver you want.
Just keep these three files together, since that's how they
The header file STRING.HPP contains the definition of the
String class. STRING.CPP contains the implementations of the
class methods. Basically, you need to compile STRING.CPP to
object form with your C++ compiler. Then #include STRING.HPP
in the source file which uses strings; link that object file
for your program with STRING.HPP, and you should be ready to
rock and roll.
A String is defined as a variable-length array of characters
which has its allocated space adjusted based on the actual
length of the array. Strings are allocated space in
multiples of the static class variable AllocIncr. As a
String grows, more space is added; as a String shrinks, so
does its allocated space. AllocIncr is set to 16, which
seems to make a good trade-off to avoid wasting space and
I'm not going to go into miles of detail on how this class
works. The header file contains many comments which detail
the purposes of instance variables and methods. It's all
quite self-explanatory; on the other hand, I'm the guy who
wrote it, so OF COURSE I understand how it works. My feeling
is that a sufficiently educated programmer should be able to
understand how I did what I did. If not, post a note on my
BBS, or send me a FidoNet mail message.
You may notice some similarities between this class and one
published in Dr. Dobb's Journal's "C in the '90s" issue with
an article called "A String Class for C++". The version in
the article is a stripped-down version of the class included
herein. Suffice it to say that articles have space
limitations, and some things needed to be cut. Also, at the
time of the Dr. Dobb's article, Zortech C++ was not able to
handle some of the things I have done in this class.
Speaking of limitations, Zortech C++ does not know how to
access static class members from within a friend function,
without the use of the scoping operator. It's not a big
deal, and the work-around (using the scoping operator) is no
Well, that's all for now, folks. Enjoy, and please provide
me with feedback. I've found this class to be amazingly
useful, and I hope you do to.
Version 1.00 is the version which appeared in the "C in the
1990's" issue of Dr. Dobb's Journal in January 1990.
Basically, that was stripped down for publication. Version
2.00 was my initial post, with the String reference
parameters being declared "const" due to a bug in an early
release of Zortech C++ 2.0. Version 2.01 fixes that problem,
and made two very trivial changes to the way enumerated
constants were named.