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

  1. //: C17:StringStorage.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("12345");
  12.   // Set the iterator indicate the first element
  13.   string::iterator it = s1.begin();
  14.   // This may copy the first to the second or 
  15.   // use reference counting to simulate a copy 
  16.   string s2 = s1;
  17.   // Either way, this statement may ONLY modify first
  18.   *it = '0';
  19.   cout << "s1 = " << s1 << endl;
  20.   cout << "s2 = " << s2 << endl;
  21. } ///:~
  22.