home *** CD-ROM | disk | FTP | other *** search
/ Reverse Code Engineering RCE CD +sandman 2000 / ReverseCodeEngineeringRceCdsandman2000.iso / RCE / Ebooks / Thinking in C++ V2 / C17 / AddStrings.cpp next >
Encoding:
C/C++ Source or Header  |  2000-05-25  |  584 b   |  24 lines

  1. //: C17:AddStrings.cpp
  2. // From Thinking in C++, 2nd Edition
  3. // Available at http://www.BruceEckel.com
  4. // (c) Bruce Eckel 1999
  5. // Copyright notice in Copyright.txt
  6. #include <string>
  7. #include <iostream>
  8. using namespace std;
  9.  
  10. int main() {
  11.   string s1("This ");
  12.   string s2("That ");
  13.   string s3("The other ");
  14.   // operator+ concatenates strings
  15.   s1 = s1 + s2;
  16.   cout << s1 << endl;
  17.   // Another way to concatenates strings
  18.   s1 += s3;
  19.   cout << s1 << endl;
  20.   // You can index the string on the right
  21.   s1 += s3 + s3[4] + "oh lala";
  22.   cout << s1 << endl;
  23. } ///:~
  24.