Advertisement
Guest User

Untitled

a guest
Apr 1st, 2015
248
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.55 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3.  
  4. void TestItOperator(const std::string& str, int length)
  5. {
  6. auto it = str.begin();
  7. auto chopped1 = std::string(it, it += length);
  8. auto chopped2 = std::string(str.begin(), it);
  9. auto chopped3 = std::string(str.begin(), str.begin() + length);
  10.  
  11. std::cout << "Orig: " << str << std::endl;
  12. std::cout << "Chop1: " << chopped1 << std::endl;
  13. std::cout << "Chop2: " << chopped2 << std::endl;
  14. std::cout << "Chop3: " << chopped2 << std::endl;
  15. }
  16.  
  17. int main()
  18. {
  19. TestItOperator("foobar", 3);
  20.  
  21. return 0;
  22. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement