#include #include using namespace std; void printList(const list &A) { for(list::const_iterator iter = A.begin();iter != A.end();iter++) cout << *iter << " "; } void testCopy(list A) { A.push_back(10); A.push_front(-1); cout << "After pass by value: "; printList(A); cout << endl; } void main() { list one; // Test copy of empty list list *two = new list(one); cout << "Printing copy of empty list: "; printList(*two); cout << endl; two->push_back(2); two->push_back(2); cout << "After adding 2,2 to copy: "; printList(*two); cout << endl; // Test copy of non-empty list one.push_front(1); one.push_back(1); list three(one); cout << "Printing copy of non-empty list: "; printList(three); cout << endl; three.push_back(3); three.push_front(3); cout << "After adding 3,3 to copy: "; printList(three); cout << endl; // Test operator= *two = three; three.push_back(0); cout << "After operator=: "; printList(*two); cout << endl; // Test parameter passing with value parameter testCopy(one); }