#include "linkedlist_bigthree.h" #include "node.h" #include #include using namespace std; void test1(){ LinkedList l; // add some numbers to the linked list for( int i = 0; i < 10; i++ ){ l.addFirst(i); } // set the value at index 5 to 100 l.set(5, 100); // empty and print out the linked list while( !l.isEmpty() ){ cout << l.removeFirst() << endl; } } void test2a(){ LinkedList l; // add some numbers to the linked list for( int i = 0; i < 10; i++ ){ l.addFirst(i); } // create another linked list LinkedList l2 = l; // set the value at index 5 to 100 for l l.set(5, 100); // empty and print out l cout << "L:"; while( !l.isEmpty() ){ cout << " " << l.removeFirst(); } cout << endl; // empty and print out l2 cout << "L2:"; while( !l2.isEmpty() ){ cout << " " << l2.removeFirst(); } cout << endl; } void test2b(){ LinkedList *l = new LinkedList(); // add some numbers to the linked list for( int i = 0; i < 10; i++ ){ l->addFirst(i); } // create another linked list LinkedList *l2 = l; // set the value at index 5 to 100 for l l->set(5, 100); // empty and print out l cout << "L:"; while( !l->isEmpty() ){ cout << " " << l->removeFirst(); } cout << endl; // empty and print out l2 cout << "L2:"; while( !l2->isEmpty() ){ cout << " " << l2->removeFirst(); } cout << endl; } void test3(){ vector v; // add some numbers to our vector for( int i = 0; i < 10; i++ ){ v.push_back(Node(i)); } // create another vector vector v2 = v; // set the value at index 5 to be 100 v[5].setValue(100); // print out v cout << "v:"; for( int i = 0; i < v.size(); i++ ){ cout << " " << v[i].value(); } cout << endl; // print out v2 cout << "v2:"; for( int i = 0; i < v2.size(); i++ ){ cout << " " << v2[i].value(); } cout << endl; } int main(){ cout << "Test 2 with objects: " << endl; test2a(); cout << endl; cout << "Test 2 with pointers: " << endl; test2b(); return 0; }