Created
May 11, 2013 20:55
-
-
Save mzdravkov/5561403 to your computer and use it in GitHub Desktop.
Test OOP homework 1. (String)
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; | |
} | |
String str2("Llama"); | |
cout << "str1.capacity():" << str1.capacity() << endl; | |
str1.append("s are cool."); | |
cout << "str1.append(\"s are cool.\"): " << str1 << endl; | |
cout << "+= == append(): " << (str2.append("s are cool.") == str1) << endl; | |
str2.push_back('!'); | |
cout << "str2.push_back(\"!\"): " << str2 << endl; | |
cout << "str2 + \"llama\": " << (str2 + "llama") << endl; | |
cout << "str2 == \"Llamas are cool.!\": " << (str2 == "Llamas are cool.!") << endl; | |
cout << "str2.find(\"Llamas\", 0): " << str2.find("Llamas", 3) << endl; | |
cout << "str2.find(\"cool\", 0): " << str2.find("cool", 3) << endl; | |
cout << "str2.find_first_of(\"L\", 0): "<< str2.find_first_of("L", 0) << endl; | |
cout << "str2.find_first_of(\"l\", 7): "<< str2.find_first_of("l", 7) << endl; | |
cout << "str2.substr(0, 5): " << str2.substr(0, 5) << endl; | |
cout << "str2.substr(11, 4): " << str2.substr(11, 4) << endl; | |
str2.push_back('!'); | |
cout << "str2.push_back(\"!\"): " << str2 << endl; | |
cout << "str2 + \"llama\": " << (str2 + "llama") << endl; | |
cout << "str2 == \"Llamas are cool.!\": " << (str2 == "Llamas are cool.!") << endl; | |
cout << "str2.find(\"Llamas\", 0): " << str2.find("Llamas", 3) << endl; | |
cout << "str2.find(\"cool\", 0): " << str2.find("cool", 3) << endl; | |
cout << "str2.find_first_of(\"L\", 0): "<< str2.find_first_of("L", 0) << endl; | |
cout << "str2.find_first_of(\"l\", 7): "<< str2.find_first_of("l", 7) << endl; | |
cout << "str2.substr(0, 5): " << str2.substr(0, 5) << endl; | |
cout << "str2.substr(11, 4): " << str2.substr(11, 4) << endl; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment