Skip to content

Instantly share code, notes, and snippets.

@mzdravkov
Created May 11, 2013 20:55
Show Gist options
  • Save mzdravkov/5561403 to your computer and use it in GitHub Desktop.
Save mzdravkov/5561403 to your computer and use it in GitHub Desktop.
Test OOP homework 1. (String)
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