#ifndef LLIST_H
#define LLIST_H
#include <ostream>
#include <stdexcept>
#define int int
usingnamespace std;
struct node_t {
int data;
node_t* next;
};
LList(){
head = NULL;
}
~LList(){
clear();
}
LList(const LList& other){
// Do the same as the default constructor
head = NULL;
// Check if the other LList is empty
if(other.head == NULL){
return;
}
// Not empty? Iterate through the other list
// and push_back on myself.
node_t* temp = other.head;
while(temp){
push_back(temp->data);
temp = temp->next;
}
}
}
The test code which the function should work with is: