//myListConstructor1.cpp #include #include #include using namespace std; int main() { string str1[] = {"A", "C", "B","D"};//array string str2[] = {"E", "F","G","H"}; // list-class var-name creates empty //list-class var-name (copies, object); //list-class var-name (beg,end); //var-name.~list(); is a destructor list Lstr1(str1, str1+4); list Lstr2(str2, str2+4); list LstrEmpty; list Lstr2Copy(Lstr1); listLstr3Iterator(str2,str2+sizeof(str2)/sizeof(string)); //---------------- cout<<"\n Lstr1.size() : " << Lstr1.size() <:: iterator it; cout<<"\n Lstr1 Origninal string \n"; for(it= Lstr1.begin(); it !=Lstr1.end(); it++) { cout <<" "<< *it; } cout<<"\n---Lstr2 Orginal string \n"; for(it= Lstr2.begin(); it !=Lstr2.end(); it++) { cout <<" "<< *it; } //------------- cout<<"\n---Lstr2Copy string \n"; for(it= Lstr2Copy.begin(); it !=Lstr2Copy.end(); it++) { cout <<" "<< *it; } //----------------- LstrEmpty.swap(Lstr1); // copy Lstr1 to Lstr2 after swap cout<<"\n----Lstr1 after swap-------\n"; for(it= Lstr1.begin(); it !=Lstr1.end(); it++) { cout <<" "<< *it; } // cout<<"\n----LstrEmpty.swap(Lstr1) after swap---\n"; for(it= LstrEmpty.begin(); it !=LstrEmpty.end(); it++) { cout <<" "<< *it; } // cout<<"\n---Lstr3Iterator array consturctor--- \n"; for(it= Lstr3Iterator.begin(); it !=Lstr3Iterator.end(); it++) { cout <<" "<< *it; } return 0; }