// FILE: str_demo.cpp // This is a small demonstration program showing how the String class is used. #include #include "MyString.h" void main( ) { const String BLANK(" "); String you_first, you_last, you, t1, t2; cout << "What is your first name? "; cin >> you_first; cout << "What is your last name? "; cin >> you_last; you = you_first + BLANK + you_last; cout << "I am happy to meet you, " << you << "." << endl; String s = "Hello Dolly!"; cout << s << endl; if(s == s) cout << "They are same.\n"; cout << (you > s) << endl; ofstream outf; outf.open("strings.txt"); cout << "Enter 3 strings with no blanks" << endl; for(int i=0; i < 3; i++) { cout << "string " << i << ": "; cin >> t1; outf << t1 << endl ; } outf.close(); cout << "---- strings in the file ----\n"; ifstream inf; inf.open("strings.txt"); for(int i=0; i < 3; i++) { cout << "string " << i << ": "; inf >> t1; cout << t1 << endl ; } }