home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD2.mdf / c / library / dos / diverses / tctnt / claslibb.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  1991-08-27  |  676 b   |  26 lines

  1. /* CLASSLIBB.CPP */
  2.  
  3. #include <strng.h>
  4. #include <list.h>
  5.  
  6. int main() {
  7.   String s1("string 1"), s2("string 2"), s3("string 3");
  8.   List l;
  9.  
  10.   //New allocates space for a new String, then the copy
  11.   //constructor copies s1 into it.  When you new an object,
  12.   //you must explicitly delete it to get the destructor to clean
  13.   //up the memory, and then have it freed.
  14.   //These new'ed objects will be deleted in the List destructor.
  15.   l.add(*(new String(s1)));
  16.   l.add(*(new String(s2)));
  17.   l.add(*(new String(s3)));
  18.  
  19.   ListIterator li = l;
  20.   while (li != 0) {
  21.     cout <<  (String &)((Object &)li) << endl;
  22.     li++;
  23.   }
  24.  
  25.   return 0; }  // end of main()
  26.