Created
May 9, 2013 12:06
-
-
Save mzdravkov/5547073 to your computer and use it in GitHub Desktop.
Example code for testing the String::iterator from OOP homework.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
String str1("Llama"); | |
cout << "str1: " << str1[0] << str1[1] << str1[2] << str1[3] << str1[4] << str1[5] << endl; | |
cout << "*str1.begin(): " << *str1.begin() << endl; | |
cout << "*str1.end() == /0: " << (*str1.end() == '\0') << endl; | |
cout << "*++++++++++str1.begin() == /0: " << (*++++++++++str1.begin() == '\0') << endl; | |
cout << "++++++++++str1.begin() != str1.end(): " << ((++++++++++str1.begin()) != str1.end()) << endl; | |
for (String::iterator i = str1.begin(); i != str1.end(); i++) { | |
cout << *i << endl; | |
} | |
// Result should be: | |
str1: Llama | |
*str1.begin(): L | |
*str1.end() == /0: 1 | |
*++++++++++str1.begin() == /0: 1 | |
++++++++++str1.begin() != str1.end(): 0 | |
L | |
l | |
a | |
m | |
a |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment