home *** CD-ROM | disk | FTP | other *** search
/ Microsoftware Monthly 19…2 Programming Power Tools / MASO9512.ISO / cpptutor / cpptutor.arj / EXAMPLES / EX07032.CPP < prev    next >
Encoding:
C/C++ Source or Header  |  1993-09-13  |  963 b   |  24 lines

  1. // \EXAMPLES\EX07032.CPP
  2. // main() function to exercise the string class
  3.  
  4. //  files in this example:
  5. // %F,15,EX0703.H%EX0703.H      definition of the class PhoneBk
  6. // %F,15,EX07031.CPP%EX07031.CPP   member functions of the class PhoneBk
  7. // EX07032.CPP   this file -- main() to exercise this class
  8.  
  9. #include "EX0703.H"
  10.  
  11. void main()
  12. {  String s1;                      // create an empty string s1
  13.    s1.append("This is s1.");       // add characters to s1
  14.    String s2(12);                  // create s2 - up to 11 chars
  15.    s2.append("This is s2.");       // add chars to s2
  16.    String s3("This is s3.");       // create s3 - convert char*
  17.    String s4(s3);                  // create s4 - copy s3
  18.    s4.append("This is s4.");       // add chars to s4
  19.    s1.print(cout) << endl;         // print s1
  20.    s2.print(cout) << endl;         // print s2
  21.    s3.print(cout) << endl;         // print s3
  22.    s4.print(cout) << endl;         // print s4
  23. }
  24.