Skip to content

Instantly share code, notes, and snippets.

@mzdravkov
Created May 9, 2013 12:06
Show Gist options
  • Save mzdravkov/5547073 to your computer and use it in GitHub Desktop.
Save mzdravkov/5547073 to your computer and use it in GitHub Desktop.
Example code for testing the String::iterator from OOP homework.
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