PRODUCT : Borland C++ NUMBER : 1013
VERSION : 3.x
OS : DOS
DATE : August 12, 1992 PAGE : 1/3
TITLE : Making string lists using Turbo Vision
The sample code provided below constructs a string list with
two strings, writes it into a file, and then reads the strings
back out into a new string list.
There is a error in the example program listed in the Turbo
Vision manual regarding TStringList/TStrListMaker (end of Ch.9).
The listing in the manual creates an instance of TStrListMaker
which is streamed to the file "STR.LST".
There are two relevant overloaded operator<< ()'s that are
used by Turbo Vision for streaming:
.1 ostream& operator<< (ostream&, TStreamable *)
and .2 ostream& operator<< (ostream&, TStreamable &)
Given the line:
ops << myStringList
The first version will be called if 'myStringList' is a pointer,
and the second one will be called if the 'myStringList' is an
actual instance of the Object. The code for the first version
properly treats new files by writing the appropriate header byte
into the file before streaming the object. After writing the
header information, the first version of the operator actually
calls the second version to perform the real streaming.
The "ostream& operator<< (ostream&, TStreamable &)" version,
however, does NOT write any header bytes into the stream which
results in an 'Abnormal Program Termination' message when the
stream is read back.
Therefore, always ensure that only pointers are used when
streaming to a new file: do NOT write actual object instances
into new files.
NOTE: When compiling with version 3.1 of Borland C++, make sure
to apply the patch BC31P1.ZIP. This patch fixes a problem with
overloading the global new operator, and this example program is
affected by this problem.
#define Uses_TStringList
PRODUCT : Borland C++ NUMBER : 1013
VERSION : 3.x
OS : DOS
DATE : August 12, 1992 PAGE : 2/3
TITLE : Making string lists using Turbo Vision
#define Uses_TStrListMaker
#define Uses_ofpstream
#define Uses_ifpstream
#include