home *** CD-ROM | disk | FTP | other *** search
/ Turbo Toolbox / Turbo_Toolbox.iso / dtx9202 / borhot / claslibb.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  1992-01-07  |  1.2 KB  |  37 lines

  1. /* ------------------------------------------------------ */
  2. /*                    CLASSLIBB.CPP                       */
  3. /*            (c) 1990 Borland International              */
  4. /*                 All rights reserved.                   */
  5. /* ------------------------------------------------------ */
  6. /*  veröffentlicht in: DOS toolbox 2'92                   */
  7. /* ------------------------------------------------------ */
  8.  
  9. #include <strng.h>
  10. #include <list.h>
  11.  
  12. int main() {
  13.   String s1("string 1"), s2("string 2"), s3("string 3");
  14.   List l;
  15.  
  16.   // New allocates space for a new String, then the copy
  17.   // constructor copies s1 into it.  When you new an object,
  18.   // you must explicitly delete it to get the destructor to
  19.   // clean up the memory, and then have it freed.
  20.   // These new'ed objects will be deleted in the List
  21.   // destructor.
  22.  
  23.   l.add(*(new String(s1)));
  24.   l.add(*(new String(s2)));
  25.   l.add(*(new String(s3)));
  26.  
  27.   ListIterator li = l;
  28.   while (li != 0) {
  29.     cout <<  (String &)((Object &)li) << endl;
  30.     li++;
  31.   }
  32.   return 0;
  33. }  // end of main()
  34. /* ------------------------------------------------------ */
  35. /*                 Ende von CLASSLIBB.CPP                 */
  36.  
  37.