#include "linkedlist.h" #include "node.h" #include #include using namespace std; void test2(){ 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 test3(){ 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 = new 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; delete l; delete l2; } int main(){ test3(); return 0; }